You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/agent-api.asciidoc
+35-40Lines changed: 35 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -539,41 +539,46 @@ Specify the maximum number of spans to capture within a request transaction
539
539
before dropping further spans.
540
540
Setting to `-1` means that spans will never be dropped.
541
541
542
-
[[flush-interval]]
543
-
===== `flushInterval`
542
+
[[api-request-time]]
543
+
===== `apiRequestTime`
544
544
545
545
* *Type:* Number
546
546
* *Default:* `10`
547
-
* *Env:* `ELASTIC_APM_FLUSH_INTERVAL`
547
+
* *Env:* `ELASTIC_APM_API_REQUEST_TIME`
548
548
549
-
The agent maintains an in-memory queue to which recorded transactions are added when they end.
550
-
Unless empty,
551
-
this queue is flushed and sent to the APM Server for processing approximately every 10 seconds.
549
+
The agent maintains an open HTTP request to the APM Server that is used to transmit the collected transactions,
550
+
spans,
551
+
and errors to the server.
552
552
553
-
Use this option to change that interval.
553
+
To avoid issues with intermittent proxies and load balancers,
554
+
the HTTP request is ended and a new one created at regular intervals controlled by this config option.
554
555
The value is expected to be in seconds.
555
556
556
-
Lowering this interval can reduce memory usage on Node.js applications with a high number of transactions.
557
-
558
557
[NOTE]
559
558
====
560
-
The queue is flushed approximately 5 seconds after the first transaction has ended on a newly started Node process.
561
-
562
-
This ensures that you don't have to wait for the entire `flushInterval` to pass for the first data to be sent to the APM Server.
563
-
From there on the `flushInterval` option is used.
559
+
The HTTP request is ended before the time threshold is reached if enough bytes are sent over it.
560
+
Use the <<api-request-size,`apiRequestSize`>> config option to control the byte threshold.
564
561
====
565
562
566
-
[NOTE]
567
-
====
568
-
After each flush of the queue,
569
-
the next flush isn't scheduled until a transaction have ended.
563
+
[[api-request-size]]
564
+
===== `apiRequestSize`
570
565
571
-
This is done to introduce variance and also ensures that empty queues are not scheduled for flushing.
566
+
* *Type:* Number
567
+
* *Default:* `1048576` (1 MiB)
568
+
* *Env:* `ELASTIC_APM_API_REQUEST_SIZE`
569
+
570
+
The agent maintains an open HTTP request to the APM Server that is used to transmit the collected transactions,
571
+
spans,
572
+
and errors to the server.
572
573
573
-
On top of that,
574
-
the actual interval is adjusted by +/- 5% between each flush.
574
+
To avoid issues with intermittent proxies and load balancers,
575
+
the HTTP request is ended and a new one created if its body becomes too large.
576
+
That limit is controlled by this config option.
577
+
The value is expected to be in bytes.
575
578
576
-
This all helps to ensure that multiple servers started at the same time will not establish connections to the APM Server simultaneously.
579
+
[NOTE]
580
+
====
581
+
The HTTP request is otherwise ended at regular intervals controlled by the <<api-request-time,`apiRequestTime`>> config option.
577
582
====
578
583
579
584
[[server-timeout]]
@@ -583,22 +588,11 @@ This all helps to ensure that multiple servers started at the same time will not
583
588
* *Default:* `30`
584
589
* *Env:* `ELASTIC_APM_SERVER_TIMEOUT`
585
590
586
-
Specify the timeout in seconds when reporting transactions to APM Server.
587
-
588
-
[[max-queue-size]]
589
-
===== `maxQueueSize`
590
-
591
-
* *Type:* Number
592
-
* *Default:* `100`
593
-
* *Env:* `ELASTIC_APM_MAX_QUEUE_SIZE`
594
-
595
-
The agent maintains an in-memory queue to which recorded transactions are added when they end.
596
-
The queue is flushed with regular intervals controlled by the <<flush-interval,`flushInterval`>> config option.
597
-
598
-
Use the `maxQueueSize` option to force a flush of the queue when it reaches a certain size (number of ended transactions) - even if the `flushInterval` time isn't reached yet.
591
+
Specify the response timeout in seconds when reporting transactions to APM Server.
599
592
600
-
Set to `-1` to disable,
601
-
in which case only `flushInterval` counts.
593
+
The timeout is applied once the agent have sent the entire request body to the APM Server.
594
+
If the response from the server takes longer than allowed by this timeout,
595
+
the HTTP request is terminated and the TCP socket closed.
The agent buffers the collected data using an in-memory queue before sending it to the APM Server.
43
-
The queue is flushed either after a specific <<performance-flush-interval,amount of time>> or when it reaches <<performance-max-queue-size,a certain size>> -
44
-
whichever comes first.
45
-
Lowering these defaults can reduce memory usage,
46
-
but will increase the number of requests to the APM Server.
42
+
The agent uses a persistent outgoing HTTP request to stream data to the APM Server.
43
+
To avoid issues with intermittent proxies and load balancers,
44
+
the HTTP request is ended and a new one created at regular intervals or when the size of the request becomes too big.
45
+
46
+
There's an overhead involved in each HTTP request:
47
+
Besides sending new HTTP headers,
48
+
the agent needs to re-send certain metadata to the APM Server each time a new HTTP request is made.
49
+
However,
50
+
if allowed by the network,
51
+
the TCP socket is reused between each HTTP request.
47
52
48
53
[float]
49
-
[[performance-flush-interval]]
50
-
==== Flush Interval
54
+
[[performance-api-request-time]]
55
+
==== Max HTTP request duration
51
56
52
-
To prevent items from staying in the queue for a long time during low activity,
53
-
the <<flush-interval,`flushInterval`>> setting is used to ensure the queue empties if anything in it is too old.
57
+
By default an HTTP request to the APM Server is ended after a maximum of 10 seconds.
58
+
Using the <<api-request-time,`apiRequestTime`>> config option,
59
+
this time limit can be modified.
54
60
55
-
Lowering the flush interval will ensure transactions are sent to the APM Server faster,
56
-
but may also result in increased HTTP traffic and CPU usage.
61
+
Lowering the time limit might be necessary if dealing with very agressive proxies,
62
+
but increasing the time limit means that the combined overhead of these HTTP requests is reduced,
63
+
as headers and metadata doesn't need to be re-sent that often.
57
64
58
65
[float]
59
-
[[performance-max-queue-size]]
60
-
==== Max Queue Size
66
+
[[performance-api-request-size]]
67
+
==== Max HTTP request size
61
68
62
-
The <<max-queue-size,`maxQueueSize`>> controls the maximum number of transactions that may remain in the queue before they must be sent.
69
+
By default an HTTP request to the APM Server is ended after approximately 1 MiB of gzip compressed data have been written to the body.
70
+
Using the <<api-request-size,`apiRequestSize`>> config option,
71
+
this time limit can be modified.
63
72
64
-
Lowering this will reduce memory consumption,
65
-
however it will increase the number of requests made to the APM Server.
73
+
Lowering the size limit might be necessary if dealing with very agressive proxies,
74
+
but increasing the size limit means that the combined overhead of these HTTP requests is reduced,
75
+
as headers and metadata doesn't need to be re-sent that often.
66
76
67
77
[float]
68
78
[[performance-server-timeout]]
69
-
=== APM Server Timeout
79
+
==== APM Server Timeout
80
+
81
+
In the event that the APM Server or the connection to the APM Server is slow or unstable,
82
+
the <<server-timeout,`serverTimeout`>> setting can be set to ensure the agent doesn't wait too long for a response.
83
+
84
+
The agent only allows for a single TCP socket to be opened to the APM Server at any given time.
85
+
This is to avoid the overhead of opening too many sockets.
86
+
If the agent is stuck waiting for a response from the previous HTTP request,
87
+
it might start dropping new data in order to keep its memory footprint low.
70
88
71
-
In the event that the connection to the APM Server is slow or unstable,
72
-
the <<server-timeout,`serverTimeout`>> setting can be set to ensure connections don't stay open too long.
73
-
If the server timeout is too high,
74
-
it may result in too many socket descriptors being held open.
0 commit comments