Skip to content

Commit

Permalink
Expose local metrics to the batch processor (#11582)
Browse files Browse the repository at this point in the history
* expose request/response counters to local exporter

* add changelog entry

* add PR number

* add local collection doc
  • Loading branch information
dmathieu authored Sep 7, 2023
1 parent 0cb613e commit 7953370
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
11 changes: 11 additions & 0 deletions changelogs/head.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,14 @@ https://github.com/elastic/apm-server/compare/8.10\...main[View commits]
[float]
==== Added
- Support and define DLM data retention period in the apmpackage
- Expose new metrics into the local batch processor {pull}11582[11582] :
- http.server.request.count
- http.server.response.valid.count
- http.server.response.errors.count
- http.server.errors.timeout
- http.server.errors.ratelimit
- grpc.server.request.count
- grpc.server.response.valid.count
- grpc.server.response.errors.count
- grpc.server.errors.timeout
- grpc.server.errors.ratelimit
4 changes: 4 additions & 0 deletions docs/monitoring/monitoring-beats.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ ifndef::serverless[]
* <<monitoring-metricbeat-collection, {metricbeat} collection>> -
{metricbeat} collects monitoring data from your {beatname_uc} instance
and sends it directly to your monitoring cluster.
* <<monitoring-local-collection, Local collection>> - Local collection sends
select monitoring data directly to the standard indices of your monitoring
cluster.
endif::[]

include::monitoring-internal-collection.asciidoc[]
include::monitoring-local-collection.asciidoc[]

ifndef::serverless[]
include::monitoring-metricbeat.asciidoc[]
Expand Down
32 changes: 32 additions & 0 deletions docs/monitoring/monitoring-local-collection.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[[monitoring-local-collection]]
= Use the select metrics emitted directly to your monitoring cluster
++++
<titleabbrev>Use local collection</titleabbrev>
++++

In 8.10 and later, we emit a selected set of metrics directly to the monitoring
cluster.
The benefit of using local collection instead of internal collection is that
the metrics are sent directly to your main monitoring index, making it easier
to view shared data.

[[select-metrics]]
== The select metrics

We only ship a select list of metrics, to avoid overwhelming your monitoring cluster.
If you need the entire set of metrics and traces we can expose, you should use
<<configuration-instrumentation,Self Instrumentation>> instead of local
collection.

Here is the list of every metrics we currently expose:

* http.server.request.count
* http.server.response.valid.count
* http.server.response.errors.count
* http.server.errors.timeout
* http.server.errors.ratelimit
* grpc.server.request.count
* grpc.server.response.valid.count
* grpc.server.response.errors.count
* grpc.server.errors.timeout
* grpc.server.errors.ratelimit
17 changes: 16 additions & 1 deletion internal/beater/beater.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import (
"github.com/elastic/apm-server/internal/beater/interceptors"
javaattacher "github.com/elastic/apm-server/internal/beater/java_attacher"
"github.com/elastic/apm-server/internal/beater/ratelimit"
"github.com/elastic/apm-server/internal/beater/request"
"github.com/elastic/apm-server/internal/elasticsearch"
"github.com/elastic/apm-server/internal/idxmgmt"
"github.com/elastic/apm-server/internal/kibana"
Expand Down Expand Up @@ -311,7 +312,21 @@ func (s *Runner) Run(ctx context.Context) error {
if err != nil {
return err
}
localExporter := telemetry.NewMetricExporter()
localExporter := telemetry.NewMetricExporter(
telemetry.WithMetricFilter([]string{
"http.server." + string(request.IDRequestCount),
"http.server." + string(request.IDResponseValidCount),
"http.server." + string(request.IDResponseErrorsCount),
"http.server." + string(request.IDResponseErrorsTimeout),
"http.server." + string(request.IDResponseErrorsRateLimit),

"grpc.server." + string(request.IDRequestCount),
"grpc.server." + string(request.IDResponseValidCount),
"grpc.server." + string(request.IDResponseErrorsCount),
"grpc.server." + string(request.IDResponseErrorsTimeout),
"grpc.server." + string(request.IDResponseErrorsRateLimit),
}),
)
meterProvider := metric.NewMeterProvider(
metric.WithReader(exporter),
metric.WithReader(metric.NewPeriodicReader(localExporter)),
Expand Down

0 comments on commit 7953370

Please sign in to comment.