-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathinstall-and-run.html
1273 lines (1221 loc) · 55.5 KB
/
install-and-run.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="UTF-8">
<title>Quick start guide | APM Overview [7.15] | Elastic</title>
<meta class="elastic" name="content" content="Quick start guide | APM Overview [7.15]">
<link rel="home" href="index.html" title="APM Overview [7.15]"/>
<link rel="up" href="index.html" title="APM Overview [7.15]"/>
<link rel="prev" href="components.html" title="Components and documentation"/>
<link rel="next" href="quick-start-overview.html" title="Quick start development environment"/>
<link rel="canonical" href="https://www.elastic.co/guide/en/apm/guide/current/apm-quick-start.html"/>
<meta class="elastic" name="product_version" content="7.15"/>
<meta class="elastic" name="product_name" content="APM"/>
<meta class="elastic" name="website_area" content="documentation"/>
<meta name="DC.type" content="Learn/Docs/APM Server/Reference/7.15"/>
<meta name="DC.subject" content="APM"/>
<meta name="DC.identifier" content="7.15"/>
<meta name="robots" content="noindex,nofollow"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdn.optimizely.com/js/18132920325.js"></script>
<link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/android-chrome-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/manifest.json">
<meta name="apple-mobile-web-app-title" content="Elastic">
<meta name="application-name" content="Elastic">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/mstile-144x144.png">
<meta name="theme-color" content="#ffffff">
<meta name="naver-site-verification" content="936882c1853b701b3cef3721758d80535413dbfd" />
<meta name="yandex-verification" content="d8a47e95d0972434" />
<meta name="localized" content="true" />
<meta name="st:robots" content="follow,index" />
<meta property="og:image" content="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt280217a63b82a734/6202d3378b1f312528798412/elastic-logo.svg" />
<meta property="og:image:width" content="500" />
<meta property="og:image:height" content="172" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<link rel="apple-touch-icon-precomposed" sizes="64x64" href="/favicon_64x64_16bit.png">
<link rel="apple-touch-icon-precomposed" sizes="32x32" href="/favicon_32x32.png">
<link rel="apple-touch-icon-precomposed" sizes="16x16" href="/favicon_16x16.png">
<!-- Give IE8 a fighting chance -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="/guide/static/styles-v1.css" />
</head>
<!--© 2015-2025 Elasticsearch B.V. -->
<!-- All Elastic documentation is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. -->
<!-- http://creativecommons.org/licenses/by-nc-nd/4.0/ -->
<body>
<!-- Google Tag Manager -->
<script>dataLayer = [];</script><noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-58RLH5" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-58RLH5');</script>
<!-- End Google Tag Manager -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-12395217-16"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-12395217-16');
</script>
<!-- Google Tag Manager for GA4 -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-KNJMG2M');</script>
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KNJMG2M" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager for GA4-->
<div id='elastic-nav' style="display:none;"></div>
<script src='https://www.elastic.co/elastic-nav.js'></script>
<div class="main-container">
<section id="content" >
<div class="content-wrapper">
<section id="guide" lang="en">
<div class="container-fluid">
<div class="row pb-3">
<div class="col-12 order-2 col-md-4 order-md-1 col-lg-3 h-almost-full-md sticky-top-md" id="left_col">
<!-- The TOC is appended here -->
</div>
<div class="col-12 order-1 col-md-8 order-md-2 col-lg-7 order-lg-2 guide-section" id="middle_col">
<!-- start body -->
<div class="page_header">
The Elastic APM integration became generally available in 7.16 — see the <a href="https://www.elastic.co/guide/en/apm/guide/current/index.html">APM Guide</a> for updated documentation. Standalone APM Server users can see the <a href="https://www.elastic.co/guide/en/apm/guide/current/legacy-apm-overview.html" title="Legacy APM Overview">Legacy APM Overview</a> and <a href="https://www.elastic.co/guide/en/apm/guide/current/overview.html" title="Legacy APM Server Reference">Legacy APM Server Reference</a>.
</div>
<div class="navheader">
<span class="prev">
<a href="components.html">« Components and documentation</a>
</span>
<span class="next">
<a href="quick-start-overview.html">Quick start development environment »</a>
</span>
</div>
<div class="book" lang="en">
<div class="titlepage">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="/guide/">Elastic Docs</a></span>
<span class="chevron-right">›</span><span class="breadcrumb-link">
<div id="related-products" class="dropdown">
<div class="related-products-title">APM:</div>
<div class="dropdown-anchor" tabindex="0">Overview<span class="dropdown-icon"></span></div>
<div class="dropdown-content">
<ul>
<li class="dropdown-category">APM</li>
<ul>
<li><a href="/guide/en/observability/current/apm.html">Observability › APM</a></li>
</ul>
<li class="dropdown-category">APM agents</li>
<ul>
<li><a href="/guide/en/apm/agent/android/current/intro.html">Android Agent Reference</a></li>
<li><a href="/guide/en/apm/agent/go/current/introduction.html">Go Agent Reference</a></li>
<li><a href="/guide/en/apm/agent/swift/current/intro.html">iOS Agent Reference</a></li>
<li><a href="/guide/en/apm/agent/java/current/intro.html">Java Agent Reference</a></li>
<li><a href="/guide/en/apm/agent/dotnet/current/intro.html">.NET Agent Reference</a></li>
<li><a href="/guide/en/apm/agent/nodejs/current/intro.html">Node.js Agent Reference</a></li>
<li><a href="/guide/en/apm/agent/php/current/intro.html">PHP Agent Reference</a></li>
<li><a href="/guide/en/apm/agent/python/current/getting-started.html">Python Agent Reference</a></li>
<li><a href="/guide/en/apm/agent/ruby/current/introduction.html">Ruby Agent Reference</a></li>
<li><a href="/guide/en/apm/agent/rum-js/current/intro.html">Real User Monitoring JavaScript Agent Reference</a></li>
</ul>
<li class="dropdown-category">APM extensions</li>
<ul>
<li><a href="/guide/en/apm/lambda/current/aws-lambda-arch.html">AWS Lambda extension</a></li>
<li><a href="/guide/en/apm/attacher/current/apm-attacher.html">Attacher</a></li>
</ul>
</ul>
</div>
</div>
</div>
<div>
<div><h1 class="title"><a id="id-1"></a>Quick start guide</h1><a class="edit_me" rel="nofollow" title="Edit this page on GitHub" href="https://github.com/elastic/apm-server/edit/7.15/docs/guide/install-and-run.asciidoc">edit</a></div>
</div>
<!--EXTRA-->
</div>
<div id="content">
<div id="url-to-v3" class="version-warning">
<strong>IMPORTANT</strong>: This documentation is no longer updated. Refer to <a href="https://www.elastic.co/support/eol">Elastic's version policy</a> and the <a href="https://www.elastic.co/docs">latest documentation</a>.
</div>
<div class="chapter">
<div class="titlepage"><div><div>
<div class="position-relative"><h2 class="title"><a id="install-and-run"></a>Quick start guide</h2><a class="edit_me" rel="nofollow" title="Edit this page on GitHub" href="https://github.com/elastic/apm-server/edit/7.15/docs/guide/install-and-run.asciidoc">edit</a></div>
</div></div></div>
<p>This guide describes how to get started quickly with Elastic APM. You’ll learn how to:</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
Spin up Elasticsearch, Kibana, and APM Server on Elasticsearch Service
</li>
<li class="listitem">
Install APM agents
</li>
<li class="listitem">
Basic configuration options
</li>
<li class="listitem">
Visualize your APM data in Kibana
</li>
</ul>
</div>
<div class="position-relative"><h3><a id="before-installation"></a>Step 1: Spin up the Elastic Stack</h3><a class="edit_me" rel="nofollow" title="Edit this page on GitHub" href="https://github.com/elastic/apm-server/edit/7.15/docs/guide/install-and-run.asciidoc">edit</a></div>
<div class="tabs" data-tab-group="spin-up-stack">
<div role="tablist" aria-label="Spin up">
<button role="tab"
aria-selected="true"
aria-controls="cloud-tab-spinup"
id="cloud-spinup">
Elasticsearch Service
</button>
<button role="tab"
aria-selected="false"
aria-controls="self-managed-tab-spinup"
id="self-managed-spinup"
tabindex="-1">
Self-managed
</button>
</div>
<div tabindex="0"
role="tabpanel"
id="cloud-tab-spinup"
aria-labelledby="cloud-spinup">
<p>There’s no faster way to get started with Elastic APM than with our hosted Elasticsearch Service on Elastic Cloud.
Elasticsearch Service is available on AWS, GCP, and Azure,
and automatically configures APM Server to work with Elasticsearch and Kibana:</p>
<div class="olist orderedlist">
<ol class="orderedlist">
<li class="listitem">
<a href="https://cloud.elastic.co/registration?page=docs&placement=docs-body" class="ulink" target="_top">Get a free trial</a>.
</li>
<li class="listitem">
Log into <a href="https://cloud.elastic.co?page=docs&placement=docs-body" class="ulink" target="_top">Elastic Cloud</a>.
</li>
<li class="listitem">
Click <span class="strong strong"><strong>Create deployment</strong></span>.
</li>
<li class="listitem">
Select <span class="strong strong"><strong>Elastic Observability</strong></span> and give your deployment a name.
</li>
<li class="listitem">
Click <span class="strong strong"><strong>Create deployment</strong></span> and copy the password for the <code class="literal">elastic</code> user.
</li>
<li class="listitem">
Select <span class="strong strong"><strong>APM</strong></span> from the menu on the left and make note of the APM endpoint and APM Server secret token.
You’ll need these in step two.
</li>
</ol>
</div>
</div>
<div tabindex="0"
role="tabpanel"
id="self-managed-tab-spinup"
aria-labelledby="self-managed-spinup"
hidden="">
<p>To install and run Elasticsearch and Kibana, see <a href="/guide/en/elastic-stack-get-started/7.15/get-started-elastic-stack.html" class="ulink" target="_top">getting started with the Elastic Stack</a>.</p>
<p>Next, install, set up, and run APM Server:</p>
<div class="olist orderedlist">
<ol class="orderedlist">
<li class="listitem">
<a href="/guide/en/apm/server/7.15/installing.html" class="ulink" target="_top">Install APM Server</a>.
</li>
<li class="listitem">
<a href="/guide/en/apm/server/7.15/apm-server-configuration.html" class="ulink" target="_top">Set up APM Server</a>
</li>
<li class="listitem">
<a href="/guide/en/apm/server/7.15/setting-up-and-running.html" class="ulink" target="_top">Start APM Server</a>.
</li>
</ol>
</div>
<p>Use the config file if you need to change the default configuration that APM Server uses to connect to Elasticsearch,
or if you need to specify credentials:</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<p><a href="/guide/en/apm/server/7.15/configuring-howto-apm-server.html" class="ulink" target="_top">Configuring APM Server</a></p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<a href="/guide/en/apm/server/7.15/configuration-process.html" class="ulink" target="_top">General configuration options</a>
</li>
<li class="listitem">
<a href="/guide/en/apm/server/7.15/elasticsearch-output.html" class="ulink" target="_top">Configure the Elasticsearch output</a>
</li>
</ul>
</div>
</li>
</ul>
</div>
<p><a id="secure-api-access"></a>If you change the listen address from <code class="literal">localhost</code> to something that is accessible from outside of the machine,
we recommend setting up firewall rules to ensure that only your own systems can access the API.
Alternatively,
you can use a <a href="/guide/en/apm/server/7.15/securing-apm-server.html" class="ulink" target="_top">TLS and a secret token or API key</a>.</p>
<p>If you have APM Server running on the same host as your service,
you can configure it to listen on a Unix domain socket.</p>
<div class="tip admon">
<div class="icon"></div>
<div class="admon_content">
<a id="more-information"></a>
<p>For detailed instructions on how to install and secure APM Server in your server environment,
including details on how to run APM Server in a highly available environment,
please see the full <a href="/guide/en/apm/server/7.15/index.html" class="ulink" target="_top">APM Server documentation</a>.</p>
</div>
</div>
</div>
</div>
<div class="position-relative"><h3><a id="agents"></a>Step 2: Install APM agents</h3><a class="edit_me" rel="nofollow" title="Edit this page on GitHub" href="https://github.com/elastic/apm-server/edit/7.15/docs/guide/install-and-run.asciidoc">edit</a></div>
<p>APM agents are written in the same language as your service.
To monitor a new service, you must install the agent and configure it with a service name, APM Server URL, and Secret token or API key.</p>
<div id="choose-service-name" class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<p><span class="strong strong"><strong>Service name</strong></span>: Service names are used to differentiate data from each of your services.
Elastic APM includes the service name field on every document that it saves in Elasticsearch.
If you change the service name after using Elastic APM,
you will see the old service name and the new service name as two separate services.
Make sure you choose a good service name before you get started.</p>
<p>The service name can only contain alphanumeric characters,
spaces, underscores, and dashes (must match <code class="literal">^[a-zA-Z0-9 _-]+$</code>).</p>
</li>
<li class="listitem">
<span class="strong strong"><strong>APM Server URL</strong></span>: The host and port that APM Server listens for events on.
</li>
<li class="listitem">
<span class="strong strong"><strong>Secret token or API key</strong></span>: Authentication method for Agent/Server communication.
See <a href="/guide/en/apm/server/7.15/secure-communication-agents.html" class="ulink" target="_top">secure communication with APM Agents</a> to learn more.
</li>
</ul>
</div>
<p>Select your service’s language for installation instructions:</p>
<div class="tabs" data-tab-group="apm-agent">
<div role="tablist" aria-label="Install">
<button role="tab"
aria-selected="false"
aria-controls="go-tab-install"
id="go-install">
Go
</button>
<button role="tab"
aria-selected="false"
aria-controls="ios-tab-install"
id="ios-install"
tabindex="-1">
iOS
</button>
<button role="tab"
aria-selected="true"
aria-controls="java-tab-install"
id="java-install"
tabindex="-1">
Java
</button>
<button role="tab"
aria-selected="false"
aria-controls="net-tab-install"
id="net-install"
tabindex="-1">
.NET
</button>
<button role="tab"
aria-selected="false"
aria-controls="node-tab-install"
id="node-install"
tabindex="-1">
Node.js
</button>
<button role="tab"
aria-selected="false"
aria-controls="php-tab-install"
id="php-install"
tabindex="-1">
PHP
</button>
<button role="tab"
aria-selected="false"
aria-controls="python-tab-install"
id="python-install"
tabindex="-1">
Python
</button>
<button role="tab"
aria-selected="false"
aria-controls="ruby-tab-install"
id="ruby-install"
tabindex="-1">
Ruby
</button>
<button role="tab"
aria-selected="false"
aria-controls="rum-tab-install"
id="rum-install"
tabindex="-1">
RUM
</button>
</div>
<div tabindex="0"
role="tabpanel"
id="go-tab-install"
aria-labelledby="go-install"
hidden="">
<p><span class="strong strong"><strong>Install the agent</strong></span></p>
<p>Install the APM agent packages for Go.</p>
<div class="pre_wrapper lang-go">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-go">go get go.elastic.co/apm</pre>
</div>
<p><span class="strong strong"><strong>Configure the agent</strong></span></p>
<p>Agents are libraries that run inside of your application process.
APM services are created programmatically based on the executable file name, or the <code class="literal">ELASTIC_APM_SERVICE_NAME</code> environment variable.</p>
<div class="pre_wrapper lang-go">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-go"># Initialize using environment variables:
# Set the service name. Allowed characters: a-z, A-Z, 0-9, -, _, and space.
# If ELASTIC_APM_SERVICE_NAME is not specified, the executable name will be used.
export ELASTIC_APM_SERVICE_NAME=
# Set custom APM Server URL. Default: http://localhost:8200.
export ELASTIC_APM_SERVER_URL=
# Use if APM Server requires a token
export ELASTIC_APM_SECRET_TOKEN=</pre>
</div>
<p><span class="strong strong"><strong>Instrument your application</strong></span></p>
<p>Instrument your Go application by using one of the provided instrumentation modules or by using the tracer API directly.</p>
<div class="pre_wrapper lang-go">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-go">import (
"net/http"
"go.elastic.co/apm/module/apmhttp"
)
func main() {
mux := http.NewServeMux()
...
http.ListenAndServe(":8080", apmhttp.Wrap(mux))
}</pre>
</div>
<p><span class="strong strong"><strong>Learn more in the agent reference</strong></span></p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<a href="/guide/en/apm/agent/go/1.x/supported-tech.html" class="ulink" target="_top">Supported technologies</a>
</li>
<li class="listitem">
<a href="/guide/en/apm/agent/go/1.x/configuration.html" class="ulink" target="_top">Advanced configuration</a>
</li>
<li class="listitem">
<a href="/guide/en/apm/agent/go/1.x/getting-started.html" class="ulink" target="_top">Detailed guide to instrumenting Go source code</a>
</li>
</ul>
</div>
</div>
<div tabindex="0"
role="tabpanel"
id="ios-tab-install"
aria-labelledby="ios-install"
hidden="">
<div class="warning admon">
<div class="icon"></div>
<div class="admon_content">
<p>This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.</p>
</div>
</div>
<p><span class="strong strong"><strong>Add the agent dependency to your project</strong></span></p>
<p>Add the Elastic APM iOS Agent as a
<a href="https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app" class="ulink" target="_top">package dependency</a>
to your Xcode project or your <code class="literal">Package.swift</code>:</p>
<div class="pre_wrapper lang-swift">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-swift">Package(
dependencies:[
.package(name: "iOSAgent", url: "[email protected]:elastic/apm-agent-ios.git", .branch("main")),
],
targets:[
.target(
name: "MyApp",
dependencies: [
.product(name: "iOSAgent", package: "iOSAgent")
]
),
])</pre>
</div>
<p><span class="strong strong"><strong>Initialize the agent</strong></span></p>
<p>If you’re using <code class="literal">SwiftUI</code> to build your app, add the following to <code class="literal">App.swift</code>:</p>
<div class="pre_wrapper lang-swift">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-swift">import SwiftUI
import iOSAgent
@main
struct MyApp: App {
init() {
var config = AgentConfiguration()
config.collectorAddress = "127.0.0.1" <a id="CO1-1"></a><i class="conum" data-value="1"></i>
config.collectorPort = 8200 <a id="CO1-2"></a><i class="conum" data-value="2"></i>
config.collectorTLS = false <a id="CO1-3"></a><i class="conum" data-value="3"></i>
config.secretToken = "<secret token>" <a id="CO1-4"></a><i class="conum" data-value="4"></i>
Agent.start(with: config)
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}</pre>
</div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO1-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>APM Server URL or IP address</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO1-2"><i class="conum" data-value="2"></i></a></p>
</td>
<td align="left" valign="top">
<p>APM Server port number</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO1-3"><i class="conum" data-value="3"></i></a></p>
</td>
<td align="left" valign="top">
<p>Enable TLS for Open telemetry exporters</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO1-4"><i class="conum" data-value="4"></i></a></p>
</td>
<td align="left" valign="top">
<p>Set secret token for APM server connection</p>
</td>
</tr>
</table>
</div>
<p>If you’re not using <code class="literal">SwiftUI</code>, you can add the same thing to your AppDelegate file:</p>
<p><code class="literal">AppDelegate.swift</code></p>
<div class="pre_wrapper lang-swift">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-swift">import UIKit
import iOSAgent
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
var config = AgentConfiguration()
config.collectorAddress = "127.0.0.1" <a id="CO2-1"></a><i class="conum" data-value="1"></i>
config.collectorPort = 8200 <a id="CO2-2"></a><i class="conum" data-value="2"></i>
config.collectorTLS = false <a id="CO2-3"></a><i class="conum" data-value="3"></i>
config.secretToken = "<secret token>" <a id="CO2-4"></a><i class="conum" data-value="4"></i>
Agent.start(with: config)
return true
}
}</pre>
</div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO2-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>APM Server url or ip address</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO2-2"><i class="conum" data-value="2"></i></a></p>
</td>
<td align="left" valign="top">
<p>APM Server port number</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO2-3"><i class="conum" data-value="3"></i></a></p>
</td>
<td align="left" valign="top">
<p>Enable TLS for Open telemetry exporters</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO2-4"><i class="conum" data-value="4"></i></a></p>
</td>
<td align="left" valign="top">
<p>Set secret token for APM server connection</p>
</td>
</tr>
</table>
</div>
</div>
<div tabindex="0"
role="tabpanel"
id="java-tab-install"
aria-labelledby="java-install">
<p><span class="strong strong"><strong>Download the APM agent</strong></span></p>
<p>Download the agent jar from <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3Aelastic-apm-agent" class="ulink" target="_top">Maven Central</a>.
Do not add the agent as a dependency to your application.</p>
<p><span class="strong strong"><strong>Start your application with the javaagent flag</strong></span></p>
<p>Add the <code class="literal">-javaagent</code> flag and configure the agent with system properties.</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
Set required service name
</li>
<li class="listitem">
Set custom APM Server URL (default: <a href="http://localhost:8200" class="ulink" target="_top">http://localhost:8200</a>)
</li>
<li class="listitem">
Set the base package of your application
</li>
</ul>
</div>
<div class="pre_wrapper lang-java">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-java">java -javaagent:/path/to/elastic-apm-agent-<version>.jar \
-Delastic.apm.service_name=my-application \
-Delastic.apm.server_urls=http://localhost:8200 \
-Delastic.apm.secret_token= \
-Delastic.apm.application_packages=org.example \
-jar my-application.jar</pre>
</div>
<p><span class="strong strong"><strong>Learn more in the agent reference</strong></span></p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<a href="/guide/en/apm/agent/java/1.x/supported-technologies-details.html" class="ulink" target="_top">Supported technologies</a>
</li>
<li class="listitem">
<a href="/guide/en/apm/agent/java/1.x/configuration.html" class="ulink" target="_top">Advanced configuration</a>
</li>
</ul>
</div>
</div>
<div tabindex="0"
role="tabpanel"
id="net-tab-install"
aria-labelledby="net-install"
hidden="">
<p><span class="strong strong"><strong>Download the APM agent</strong></span></p>
<p>Add the agent packages from <a href="https://www.nuget.org/packages?q=Elastic.apm" class="ulink" target="_top">NuGet</a> to your .NET application.
There are multiple NuGet packages available for different use cases.</p>
<p>For an ASP.NET Core application with Entity Framework Core, download the
<a href="https://www.nuget.org/packages/Elastic.Apm.NetCoreAll" class="ulink" target="_top">Elastic.Apm.NetCoreAll</a> package.
This package will automatically add every agent component to your application.</p>
<p>To minimize the number of dependencies, you can use the
<a href="https://www.nuget.org/packages/Elastic.Apm.AspNetCore" class="ulink" target="_top">Elastic.Apm.AspNetCore</a> package for just ASP.NET Core monitoring, or the
<a href="https://www.nuget.org/packages/Elastic.Apm.EntityFrameworkCore" class="ulink" target="_top">Elastic.Apm.EfCore</a> package for just Entity Framework Core monitoring.</p>
<p>If you only want to use the public agent API for manual instrumentation, use the
<a href="https://www.nuget.org/packages/Elastic.Apm" class="ulink" target="_top">Elastic.Apm</a> package.</p>
<p><span class="strong strong"><strong>Add the agent to the application</strong></span></p>
<p>For an ASP.NET Core application with the <code class="literal">Elastic.Apm.NetCoreAll</code> package,
call the <code class="literal">UseAllElasticApm</code> method in the <code class="literal">Configure</code> method within the <code class="literal">Startup.cs</code> file:</p>
<div class="pre_wrapper lang-dotnet">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-dotnet">public class Startup
{
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseAllElasticApm(Configuration);
//…rest of the method
}
//…rest of the class
}</pre>
</div>
<p>Passing an <code class="literal">IConfiguration</code> instance is optional and by doing so,
the agent will read config settings through this <code class="literal">IConfiguration</code> instance, for example,
from the <code class="literal">appsettings.json</code> file:</p>
<div class="pre_wrapper lang-json">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-json">{
"ElasticApm": {
"SecretToken": "",
"ServerUrls": "http://localhost:8200", //Set custom APM Server URL (default: http://localhost:8200)
"ServiceName" : "MyApp", //allowed characters: a-z, A-Z, 0-9, -, _, and space. Default is the entry assembly of the application
}
}</pre>
</div>
<p>If you don’t pass an <code class="literal">IConfiguration</code> instance to the agent, for example, in a non-ASP.NET Core application,
you can configure the agent with environment variables.
See the agent reference for more information.</p>
<p><span class="strong strong"><strong>Learn more in the agent reference</strong></span></p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<a href="/guide/en/apm/agent/dotnet/1.x/supported-technologies.html" class="ulink" target="_top">Supported technologies</a>
</li>
<li class="listitem">
<a href="/guide/en/apm/agent/dotnet/1.x/configuration.html" class="ulink" target="_top">Advanced configuration</a>
</li>
</ul>
</div>
</div>
<div tabindex="0"
role="tabpanel"
id="node-tab-install"
aria-labelledby="node-install"
hidden="">
<p><span class="strong strong"><strong>Install the APM agent</strong></span></p>
<p>Install the APM agent for Node.js as a dependency to your application.</p>
<div class="pre_wrapper lang-js">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-js">npm install elastic-apm-node --save</pre>
</div>
<p><span class="strong strong"><strong>Configure the agent</strong></span></p>
<p>Agents are libraries that run inside of your application process. APM services are created programmatically based on the <code class="literal">serviceName</code>.
This agent supports a variety of frameworks but can also be used with your custom stack.</p>
<div class="pre_wrapper lang-js">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-js">// Add this to the VERY top of the first file loaded in your app
var apm = require('elastic-apm-node').start({
// Override service name from package.json
// Allowed characters: a-z, A-Z, 0-9, -, _, and space
serviceName: '',
// Use if APM Server requires a token
secretToken: '',
// Set custom APM Server URL (default: http://localhost:8200)
serverUrl: ''
})</pre>
</div>
<p><span class="strong strong"><strong>Learn more in the agent reference</strong></span></p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<a href="/guide/en/apm/agent/nodejs/4.x/supported-technologies.html" class="ulink" target="_top">Supported technologies</a>
</li>
<li class="listitem">
<a href="/guide/en/apm/agent/nodejs/4.x/advanced-setup.html" class="ulink" target="_top">Babel/ES Modules</a>
</li>
<li class="listitem">
<a href="/guide/en/apm/agent/nodejs/4.x/configuring-the-agent.html" class="ulink" target="_top">Advanced configuration</a>
</li>
</ul>
</div>
</div>
<div tabindex="0"
role="tabpanel"
id="php-tab-install"
aria-labelledby="php-install"
hidden="">
<p><span class="strong strong"><strong>Install the agent</strong></span></p>
<p>Install the PHP agent using one of the <a href="https://github.com/elastic/apm-agent-php/releases" class="ulink" target="_top">published packages</a>.</p>
<p>To use the RPM Package (RHEL/CentOS and Fedora):</p>
<div class="pre_wrapper lang-php">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-php">rpm -ivh <package-file>.rpm</pre>
</div>
<p>To use the DEB package (Debian and Ubuntu):</p>
<div class="pre_wrapper lang-php">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-php">dpkg -i <package-file>.deb</pre>
</div>
<p>To use the APK package (Alpine):</p>
<div class="pre_wrapper lang-php">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-php">apk add --allow-untrusted <package-file>.apk</pre>
</div>
<p>If you can’t find your distribution,
you can install the agent by <a href="/guide/en/apm/agent/php/1.x/setup.html" class="ulink" target="_top">building it from the source</a>.</p>
<p><span class="strong strong"><strong>Configure the agent</strong></span></p>
<p>Configure your agent inside of the <code class="literal">php.ini</code> file:</p>
<div class="pre_wrapper lang-ini">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-ini">elastic_apm.server_url=http://localhost:8200
elastic_apm.secret_token=SECRET_TOKEN
elastic_apm.service_name="My-service"</pre>
</div>
<p><span class="strong strong"><strong>Learn more in the agent reference</strong></span></p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<a href="/guide/en/apm/agent/php/1.x/supported-technologies.html" class="ulink" target="_top">Supported technologies</a>
</li>
<li class="listitem">
<a href="/guide/en/apm/agent/php/1.x/configuration.html" class="ulink" target="_top">Configuration</a>
</li>
</ul>
</div>
</div>
<div tabindex="0"
role="tabpanel"
id="python-tab-install"
aria-labelledby="python-install"
hidden="">
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
Django
</span>
</dt>
<dd>
<p><span class="strong strong"><strong>Install the APM agent</strong></span></p>
<p>Install the APM agent for Python as a dependency.</p>
<div class="pre_wrapper lang-python">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-python">$ pip install elastic-apm</pre>
</div>
<p><span class="strong strong"><strong>Configure the agent</strong></span></p>
<p>Agents are libraries that run inside of your application process.
APM services are created programmatically based on the <code class="literal">SERVICE_NAME</code>.</p>
<div class="pre_wrapper lang-python">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-python"># Add the agent to the installed apps
INSTALLED_APPS = (
'elasticapm.contrib.django',
# ...
)
ELASTIC_APM = {
# Set required service name. Allowed characters:
# a-z, A-Z, 0-9, -, _, and space
'SERVICE_NAME': '',
# Use if APM Server requires a token
'SECRET_TOKEN': '',
# Set custom APM Server URL (default: http://localhost:8200)
'SERVER_URL': '',
}
# To send performance metrics, add our tracing middleware:
MIDDLEWARE = (
'elasticapm.contrib.django.middleware.TracingMiddleware',
#...
)</pre>
</div>
</dd>
<dt>
<span class="term">
Flask
</span>
</dt>
<dd>
<p><span class="strong strong"><strong>Install the APM agent</strong></span></p>
<p>Install the APM agent for Python as a dependency.</p>
<div class="pre_wrapper lang-python">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-python">$ pip install elastic-apm[flask]</pre>
</div>
<p><span class="strong strong"><strong>Configure the agent</strong></span></p>
<p>Agents are libraries that run inside of your application process.
APM services are created programmatically based on the <code class="literal">SERVICE_NAME</code>.</p>
<div class="pre_wrapper lang-python">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-python"># initialize using environment variables
from elasticapm.contrib.flask import ElasticAPM
app = Flask(__name__)
apm = ElasticAPM(app)
# or configure to use ELASTIC_APM in your application settings
from elasticapm.contrib.flask import ElasticAPM
app.config['ELASTIC_APM'] = {
# Set required service name. Allowed characters:
# a-z, A-Z, 0-9, -, _, and space
'SERVICE_NAME': '',
# Use if APM Server requires a token
'SECRET_TOKEN': '',
# Set custom APM Server URL (default: http://localhost:8200)
'SERVER_URL': '',
}
apm = ElasticAPM(app)</pre>
</div>
</dd>
</dl>
</div>
<p><span class="strong strong"><strong>Learn more in the agent reference</strong></span></p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<a href="/guide/en/apm/agent/python/5.x/supported-technologies.html" class="ulink" target="_top">Supported technologies</a>
</li>
<li class="listitem">
<a href="/guide/en/apm/agent/python/5.x/configuration.html" class="ulink" target="_top">Advanced configuration</a>
</li>
</ul>
</div>
</div>
<div tabindex="0"
role="tabpanel"
id="ruby-tab-install"
aria-labelledby="ruby-install"
hidden="">
<p><span class="strong strong"><strong>Install the APM agent</strong></span></p>
<p>Add the agent to your Gemfile.</p>
<div class="pre_wrapper lang-ruby">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-ruby">gem 'elastic-apm'</pre>
</div>
<p><span class="strong strong"><strong>Configure the agent</strong></span></p>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
Ruby on Rails
</span>
</dt>
<dd>
<p>APM is automatically started when your app boots.
Configure the agent by creating the config file <code class="literal">config/elastic_apm.yml</code>:</p>
<div class="pre_wrapper lang-ruby">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-ruby"># config/elastic_apm.yml:
# Set service name - allowed characters: a-z, A-Z, 0-9, -, _ and space
# Defaults to the name of your Rails app
service_name: 'my-service'
# Use if APM Server requires a token
secret_token: ''
# Set custom APM Server URL (default: http://localhost:8200)
server_url: 'http://localhost:8200'</pre>
</div>
</dd>
<dt>
<span class="term">
Rack
</span>
</dt>
<dd>
<p>For Rack or a compatible framework, like Sinatra, include the middleware in your app and start the agent.</p>
<div class="pre_wrapper lang-ruby">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-ruby"># config.ru
require 'sinatra/base'
class MySinatraApp < Sinatra::Base
use ElasticAPM::Middleware
# ...
end
ElasticAPM.start(
app: MySinatraApp, # required
config_file: '' # optional, defaults to config/elastic_apm.yml
)
run MySinatraApp
at_exit { ElasticAPM.stop }</pre>
</div>
<p><span class="strong strong"><strong>Create a config file</strong></span></p>
<p>Create a config file config/elastic_apm.yml:</p>
<div class="pre_wrapper lang-ruby">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-ruby"># config/elastic_apm.yml:
# Set service name - allowed characters: a-z, A-Z, 0-9, -, _ and space
# Defaults to the name of your Rack app's class.
service_name: 'my-service'
# Use if APM Server requires a token
secret_token: ''
# Set custom APM Server URL (default: http://localhost:8200)
server_url: 'http://localhost:8200'</pre>
</div>
</dd>
</dl>
</div>
<p><span class="strong strong"><strong>Learn more in the agent reference</strong></span></p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<a href="/guide/en/apm/agent/ruby/4.x/supported-technologies.html" class="ulink" target="_top">Supported technologies</a>
</li>
<li class="listitem">
<a href="/guide/en/apm/agent/ruby/4.x/configuration.html" class="ulink" target="_top">Advanced configuration</a>
</li>
</ul>
</div>
</div>
<div tabindex="0"
role="tabpanel"
id="rum-tab-install"
aria-labelledby="rum-install"
hidden="">
<p><span class="strong strong"><strong>Enable Real User Monitoring support in APM Server</strong></span></p>
<p>APM Server disables RUM support by default.
To enable it, set <code class="literal">apm-server.rum.enabled: true</code> in your APM Server configuration file.</p>
<p><span class="strong strong"><strong>Set up the agent</strong></span></p>
<p>Once RUM support enabled, you can set up the RUM agent.
There are two ways to do this: add the agent as a dependency,
or set it up with <code class="literal"><script></code> tags.</p>
<p><span class="strong strong"><strong>Set up the agent as a dependency</strong></span></p>
<p>You can install the agent as a dependency to your application with <code class="literal">npm install @elastic/apm-rum --save</code>.</p>
<p>The agent can then be initialized and configured in your application like this:</p>
<div class="pre_wrapper lang-js">
<div class="console_code_copy" title="Copy to clipboard"></div>
<pre class="programlisting prettyprint lang-js">import { init as initApm } from '@elastic/apm-rum'
var apm = initApm({
// Set required service name (allowed characters: a-z, A-Z, 0-9, -, _, and space)
serviceName: 'your-app-name',
// Set custom APM Server URL (default: http://localhost:8200)
serverUrl: '',
// Set service version (required for source map feature)
serviceVersion: ''
})</pre>
</div>
<p>Framework integrations, like React or Angular, have custom dependencies.
See <a href="/guide/en/apm/agent/rum-js/5.x/framework-integrations.html" class="ulink" target="_top">framework integrations</a> for more information.</p>
<p><span class="strong strong"><strong>Set up the agent with <code class="literal"><script></code> tags</strong></span></p>