Skip to content

Commit

Permalink
Restructure model.Metricset (#5739)
Browse files Browse the repository at this point in the history
A few smallish changes to the model.Metricset type, for
future-proofing. The goal is to make the type suitable for
generating transformation to beat.Events logic later, while
making the type better suited to protobuf definition in the
short term.

model.Metricset.Samples is now a map, instead of a slice of
named metrics, and the metrics fields are added as flat
dotted field namess rather than hierarchical objects.

In the future we will send the samples map as-is (with values,
type, and unit) to Elasticsearch and perform transformation
to top-level metrics fields and dynamic templates completely
in the ingest pipeline.

model.Sample is now called model.MetricsetSample.

We no longer set "_doc_count" in transformation; this is now
part of the type and is set in transaction metrics aggregation
for "transaction.duration.histogram", the only metric where it
is expected to be set.
  • Loading branch information
axw authored Jul 16, 2021
1 parent e63fd60 commit 4ac8c60
Show file tree
Hide file tree
Showing 30 changed files with 494 additions and 1,004 deletions.
8 changes: 5 additions & 3 deletions agentcfg/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ func (r Reporter) Run(ctx context.Context) error {
batch := make(model.Batch, 0, len(applied))
for etag := range applied {
batch = append(batch, model.APMEvent{Metricset: &model.Metricset{
Name: "agent_config",
Labels: common.MapStr{"etag": etag},
Samples: []model.Sample{{Name: "agent_config_applied", Value: 1}},
Name: "agent_config",
Labels: common.MapStr{"etag": etag},
Samples: map[string]model.MetricsetSample{
"agent_config_applied": {Value: 1},
},
}})
}
// Reset applied map, so that we report only configs applied
Expand Down
10 changes: 1 addition & 9 deletions apmpackage/apm/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -534,15 +534,7 @@ Metrics are written to `metrics-apm.app.*`, `metrics-apm.internal.*`, and `metri
"event": {
"ingested": "2020-04-22T14:55:05.425020Z"
},
"go": {
"memstats": {
"heap": {
"sys": {
"bytes": 6520832
}
}
}
},
"go.memstats.heap.sys.bytes": 6520832,
"host": {
"ip": "127.0.0.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,11 +658,7 @@
"container": {
"id": "8ec7ceb990749e79b37f6dc6cd3628633618d6ce412553a552a0fa6b69419ad4"
},
"dotted": {
"float": {
"gauge": 6.12
}
},
"dotted.float.gauge": 6.12,
"double_gauge": 3.141592653589793,
"ecs": {
"version": "1.10.0"
Expand Down Expand Up @@ -697,19 +693,7 @@
},
"long_gauge": 3147483648,
"metricset.name": "span_breakdown",
"negative": {
"d": {
"o": {
"t": {
"t": {
"e": {
"d": -1022
}
}
}
}
}
},
"negative.d.o.t.t.e.d": -1022,
"observer": {
"ephemeral_id": "00000000-0000-0000-0000-000000000000",
"hostname": "",
Expand Down Expand Up @@ -752,34 +736,20 @@
},
"short_counter": 227,
"span": {
"self_time": {
"count": 1,
"sum": {
"us": 633.288
}
},
"subtype": "mysql",
"type": "db"
},
"span.self_time.count": 1,
"span.self_time.sum.us": 633.288,
"transaction": {
"breakdown": {
"count": 12
},
"duration": {
"count": 2,
"sum": {
"us": 12
}
},
"name": "GET/",
"self_time": {
"count": 2,
"sum": {
"us": 10
}
},
"type": "request"
}
},
"transaction.breakdown.count": 12,
"transaction.duration.count": 2,
"transaction.duration.sum.us": 12,
"transaction.self_time.count": 2,
"transaction.self_time.sum.us": 10
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
"version": "3.14.0"
},
"byte_counter": 1,
"dotted": {
"float": {
"gauge": 6.12
}
},
"dotted.float.gauge": 6.12,
"double_gauge": 3.141592653589793,
"ecs": {
"version": "1.10.0"
Expand All @@ -30,19 +26,7 @@
},
"long_gauge": 3147483648,
"metricset.name": "span_breakdown",
"negative": {
"d": {
"o": {
"t": {
"t": {
"e": {
"d": -1022
}
}
}
}
}
},
"negative.d.o.t.t.e.d": -1022,
"observer": {
"ephemeral_id": "00000000-0000-0000-0000-000000000000",
"hostname": "",
Expand All @@ -69,34 +53,20 @@
},
"short_counter": 227,
"span": {
"self_time": {
"count": 1,
"sum": {
"us": 633.288
}
},
"subtype": "mysql",
"type": "db"
},
"span.self_time.count": 1,
"span.self_time.sum.us": 633.288,
"transaction": {
"breakdown": {
"count": 12
},
"duration": {
"count": 2,
"sum": {
"us": 12
}
},
"name": "GET /",
"self_time": {
"count": 2,
"sum": {
"us": 10
}
},
"type": "request"
},
"transaction.breakdown.count": 12,
"transaction.duration.count": 2,
"transaction.duration.sum.us": 12,
"transaction.self_time.count": 2,
"transaction.self_time.sum.us": 10,
"user": {
"email": "[email protected]",
"id": "axb123hg",
Expand All @@ -112,15 +82,7 @@
"ecs": {
"version": "1.10.0"
},
"go": {
"memstats": {
"heap": {
"sys": {
"bytes": 6520832
}
}
}
},
"go.memstats.heap.sys.bytes": 6520832,
"host": {
"ip": "127.0.0.1"
},
Expand Down Expand Up @@ -200,22 +162,8 @@
"name": "node-1"
}
},
"system": {
"process": {
"cgroup": {
"memory": {
"mem": {
"limit": {
"bytes": 2048
},
"usage": {
"bytes": 1024
}
}
}
}
}
},
"system.process.cgroup.memory.mem.limit.bytes": 2048,
"system.process.cgroup.memory.mem.usage.bytes": 1024,
"user": {
"email": "[email protected]",
"id": "axb123hg",
Expand Down Expand Up @@ -263,36 +211,14 @@
"name": "node-1"
}
},
"system": {
"process": {
"cgroup": {
"cpu": {
"cfs": {
"period": {
"us": 1024
},
"quota": {
"us": 2048
}
},
"id": 2048,
"stats": {
"periods": 2048,
"throttled": {
"ns": 2048,
"periods": 2048
}
}
},
"cpuacct": {
"id": 2048,
"total": {
"ns": 2048
}
}
}
}
},
"system.process.cgroup.cpu.cfs.period.us": 1024,
"system.process.cgroup.cpu.cfs.quota.us": 2048,
"system.process.cgroup.cpu.id": 2048,
"system.process.cgroup.cpu.stats.periods": 2048,
"system.process.cgroup.cpu.stats.throttled.ns": 2048,
"system.process.cgroup.cpu.stats.throttled.periods": 2048,
"system.process.cgroup.cpuacct.id": 2048,
"system.process.cgroup.cpuacct.total.ns": 2048,
"user": {
"email": "[email protected]",
"id": "axb123hg",
Expand All @@ -301,7 +227,6 @@
},
{
"@timestamp": "2017-05-30T18:53:41.366Z",
"_doc_count": 6,
"_metric_descriptions": {
"latency_distribution": {
"type": "histogram",
Expand Down
Loading

0 comments on commit 4ac8c60

Please sign in to comment.