Skip to content

Commit

Permalink
[receiver/elasticsearch]: emit segment metrics with primary shards ag…
Browse files Browse the repository at this point in the history
…gregation (open-telemetry#16047)

feat: emit segment metrics with primary shards aggregation
  • Loading branch information
aboguszewski-sumo authored and shalper2 committed Dec 6, 2022
1 parent 1aaafe7 commit 94b2b7d
Show file tree
Hide file tree
Showing 3 changed files with 250 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .chloggen/elasticserach-receiver-segments-primary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: elasticsearchreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: emit missing data points related to segments, aggregated by primary shards

# One or more tracking issues related to the change
issues: [14635]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
30 changes: 30 additions & 0 deletions receiver/elasticsearchreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,16 @@ func (r *elasticsearchScraper) scrapeOneIndexMetrics(now pcommon.Timestamp, name
r.mb.RecordElasticsearchIndexSegmentsCountDataPoint(
now, stats.Total.SegmentsStats.Count, metadata.AttributeIndexAggregationTypeTotal,
)
r.mb.RecordElasticsearchIndexSegmentsCountDataPoint(
now, stats.Primaries.SegmentsStats.Count, metadata.AttributeIndexAggregationTypePrimaryShards,
)

r.mb.RecordElasticsearchIndexSegmentsSizeDataPoint(
now, stats.Total.SegmentsStats.MemoryInBy, metadata.AttributeIndexAggregationTypeTotal,
)
r.mb.RecordElasticsearchIndexSegmentsSizeDataPoint(
now, stats.Primaries.SegmentsStats.MemoryInBy, metadata.AttributeIndexAggregationTypePrimaryShards,
)

r.mb.RecordElasticsearchIndexSegmentsMemoryDataPoint(
now,
Expand All @@ -412,6 +418,30 @@ func (r *elasticsearchScraper) scrapeOneIndexMetrics(now pcommon.Timestamp, name
metadata.AttributeIndexAggregationTypeTotal,
metadata.AttributeSegmentsMemoryObjectTypeTerm,
)
r.mb.RecordElasticsearchIndexSegmentsMemoryDataPoint(
now,
stats.Primaries.SegmentsStats.DocumentValuesMemoryInBy,
metadata.AttributeIndexAggregationTypePrimaryShards,
metadata.AttributeSegmentsMemoryObjectTypeDocValue,
)
r.mb.RecordElasticsearchIndexSegmentsMemoryDataPoint(
now,
stats.Primaries.SegmentsStats.FixedBitSetMemoryInBy,
metadata.AttributeIndexAggregationTypePrimaryShards,
metadata.AttributeSegmentsMemoryObjectTypeFixedBitSet,
)
r.mb.RecordElasticsearchIndexSegmentsMemoryDataPoint(
now,
stats.Primaries.SegmentsStats.IndexWriterMemoryInBy,
metadata.AttributeIndexAggregationTypePrimaryShards,
metadata.AttributeSegmentsMemoryObjectTypeIndexWriter,
)
r.mb.RecordElasticsearchIndexSegmentsMemoryDataPoint(
now,
stats.Primaries.SegmentsStats.TermsMemoryInBy,
metadata.AttributeIndexAggregationTypePrimaryShards,
metadata.AttributeSegmentsMemoryObjectTypeTerm,
)

r.mb.RecordElasticsearchIndexTranslogOperationsDataPoint(
now, stats.Total.TranslogStats.Operations, metadata.AttributeIndexAggregationTypeTotal,
Expand Down
204 changes: 204 additions & 0 deletions receiver/elasticsearchreceiver/testdata/expected_metrics/full.json
Original file line number Diff line number Diff line change
Expand Up @@ -2679,6 +2679,19 @@
],
"startTimeUnixNano": "1661811689941624000",
"timeUnixNano": "1661811689943245000"
},
{
"asInt": "5",
"attributes": [
{
"key": "aggregation",
"value": {
"stringValue": "primary_shards"
}
}
],
"startTimeUnixNano": "1661811689941624000",
"timeUnixNano": "1661811689943245000"
}
]
},
Expand All @@ -2703,6 +2716,19 @@
],
"startTimeUnixNano": "1661811689941624000",
"timeUnixNano": "1661811689943245000"
},
{
"asInt": "5460",
"attributes": [
{
"key": "aggregation",
"value": {
"stringValue": "primary_shards"
}
}
],
"startTimeUnixNano": "1661811689941624000",
"timeUnixNano": "1661811689943245000"
}
]
},
Expand Down Expand Up @@ -2790,6 +2816,82 @@
],
"startTimeUnixNano": "1661811689941624000",
"timeUnixNano": "1661811689943245000"
},
{
"asInt": "2560",
"attributes": [
{
"key": "aggregation",
"value": {
"stringValue": "primary_shards"
}
},
{
"key": "object",
"value": {
"stringValue": "term"
}
}
],
"startTimeUnixNano": "1661811689941624000",
"timeUnixNano": "1661811689943245000"
},
{
"asInt": "380",
"attributes": [
{
"key": "aggregation",
"value": {
"stringValue": "primary_shards"
}
},
{
"key": "object",
"value": {
"stringValue": "doc_value"
}
}
],
"startTimeUnixNano": "1661811689941624000",
"timeUnixNano": "1661811689943245000"
},
{
"asInt": "37",
"attributes": [
{
"key": "aggregation",
"value": {
"stringValue": "primary_shards"
}
},
{
"key": "object",
"value": {
"stringValue": "index_writer"
}
}
],
"startTimeUnixNano": "1661811689941624000",
"timeUnixNano": "1661811689943245000"
},
{
"asInt": "21",
"attributes": [
{
"key": "aggregation",
"value": {
"stringValue": "primary_shards"
}
},
{
"key": "object",
"value": {
"stringValue": "fixed_bit_set"
}
}
],
"startTimeUnixNano": "1661811689941624000",
"timeUnixNano": "1661811689943245000"
}
]
},
Expand Down Expand Up @@ -3079,6 +3181,19 @@
],
"startTimeUnixNano": "1661811689941624000",
"timeUnixNano": "1661811689943245000"
},
{
"asInt": "5",
"attributes": [
{
"key": "aggregation",
"value": {
"stringValue": "primary_shards"
}
}
],
"startTimeUnixNano": "1661811689941624000",
"timeUnixNano": "1661811689943245000"
}
]
},
Expand All @@ -3103,6 +3218,19 @@
],
"startTimeUnixNano": "1661811689941624000",
"timeUnixNano": "1661811689943245000"
},
{
"asInt": "5460",
"attributes": [
{
"key": "aggregation",
"value": {
"stringValue": "primary_shards"
}
}
],
"startTimeUnixNano": "1661811689941624000",
"timeUnixNano": "1661811689943245000"
}
]
},
Expand Down Expand Up @@ -3190,6 +3318,82 @@
],
"startTimeUnixNano": "1661811689941624000",
"timeUnixNano": "1661811689943245000"
},
{
"asInt": "2560",
"attributes": [
{
"key": "aggregation",
"value": {
"stringValue": "primary_shards"
}
},
{
"key": "object",
"value": {
"stringValue": "term"
}
}
],
"startTimeUnixNano": "1661811689941624000",
"timeUnixNano": "1661811689943245000"
},
{
"asInt": "380",
"attributes": [
{
"key": "aggregation",
"value": {
"stringValue": "primary_shards"
}
},
{
"key": "object",
"value": {
"stringValue": "doc_value"
}
}
],
"startTimeUnixNano": "1661811689941624000",
"timeUnixNano": "1661811689943245000"
},
{
"asInt": "37",
"attributes": [
{
"key": "aggregation",
"value": {
"stringValue": "primary_shards"
}
},
{
"key": "object",
"value": {
"stringValue": "index_writer"
}
}
],
"startTimeUnixNano": "1661811689941624000",
"timeUnixNano": "1661811689943245000"
},
{
"asInt": "21",
"attributes": [
{
"key": "aggregation",
"value": {
"stringValue": "primary_shards"
}
},
{
"key": "object",
"value": {
"stringValue": "fixed_bit_set"
}
}
],
"startTimeUnixNano": "1661811689941624000",
"timeUnixNano": "1661811689943245000"
}
]
},
Expand Down

0 comments on commit 94b2b7d

Please sign in to comment.