Skip to content

Commit

Permalink
[receiver/elasticsearch] Add active index merge count metric (#34388)
Browse files Browse the repository at this point in the history
**Description:** <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
This adds a metric for the currently active index merges to help monitor
the status of an Elasticsearch cluster.

**Link to tracking Issue:** <Issue number if applicable>
Resolves
#34387

**Testing:** <Describe what testing was performed and which tests were
added.>
Updated existing tests to account for enabled metric.
  • Loading branch information
crobert-1 authored Aug 2, 2024
1 parent 23013d3 commit 2027679
Show file tree
Hide file tree
Showing 13 changed files with 198 additions and 8 deletions.
27 changes: 27 additions & 0 deletions .chloggen/es_add_metric.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# 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: Add metric for active index merges

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [34387]

# (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:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
14 changes: 14 additions & 0 deletions receiver/elasticsearchreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,20 @@ The number of documents for an index.
| state | The state of the document. | Str: ``active``, ``deleted`` |
| aggregation | Type of shard aggregation for index statistics | Str: ``primary_shards``, ``total`` |
### elasticsearch.index.operations.merge.current
The number of currently active segment merges
| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {merges} | Gauge | Int |
#### Attributes
| Name | Description | Values |
| ---- | ----------- | ------ |
| aggregation | Type of shard aggregation for index statistics | Str: ``primary_shards``, ``total`` |
### elasticsearch.index.operations.merge.docs_count
The total number of documents in merge operations for an index.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ all_set:
enabled: true
elasticsearch.index.operations.completed:
enabled: true
elasticsearch.index.operations.merge.current:
enabled: true
elasticsearch.index.operations.merge.docs_count:
enabled: true
elasticsearch.index.operations.merge.size:
Expand Down Expand Up @@ -234,6 +236,8 @@ none_set:
enabled: false
elasticsearch.index.operations.completed:
enabled: false
elasticsearch.index.operations.merge.current:
enabled: false
elasticsearch.index.operations.merge.docs_count:
enabled: false
elasticsearch.index.operations.merge.size:
Expand Down
1 change: 1 addition & 0 deletions receiver/elasticsearchreceiver/internal/model/nodestats.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ type BasicIndexOperation struct {

type MergeOperations struct {
BasicIndexOperation
Current int64 `json:"current"`
TotalSizeInBytes int64 `json:"total_size_in_bytes"`
TotalDocs int64 `json:"total_docs"`
}
Expand Down
7 changes: 7 additions & 0 deletions receiver/elasticsearchreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,13 @@ metrics:
value_type: int
attributes: [index_aggregation_type]
enabled: false
elasticsearch.index.operations.merge.current:
description: The number of currently active segment merges
unit: "{merges}"
gauge:
value_type: int
attributes: [ index_aggregation_type ]
enabled: false
elasticsearch.index.segments.count:
description: Number of segments of an index.
unit: "{segments}"
Expand Down
4 changes: 4 additions & 0 deletions receiver/elasticsearchreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,10 @@ func (r *elasticsearchScraper) scrapeOneIndexMetrics(now pcommon.Timestamp, name
now, stats.Total.MergeOperations.TotalDocs, metadata.AttributeIndexAggregationTypeTotal,
)

r.mb.RecordElasticsearchIndexOperationsMergeCurrentDataPoint(
now, stats.Total.MergeOperations.Current, metadata.AttributeIndexAggregationTypeTotal,
)

r.mb.RecordElasticsearchIndexShardsSizeDataPoint(
now, stats.Total.StoreInfo.SizeInBy, metadata.AttributeIndexAggregationTypeTotal,
)
Expand Down
2 changes: 2 additions & 0 deletions receiver/elasticsearchreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func TestScraper(t *testing.T) {

config.Metrics.ElasticsearchIndexOperationsMergeSize.Enabled = true
config.Metrics.ElasticsearchIndexOperationsMergeDocsCount.Enabled = true
config.Metrics.ElasticsearchIndexOperationsMergeCurrent.Enabled = true
config.Metrics.ElasticsearchIndexSegmentsCount.Enabled = true
config.Metrics.ElasticsearchIndexSegmentsSize.Enabled = true
config.Metrics.ElasticsearchIndexSegmentsMemory.Enabled = true
Expand Down Expand Up @@ -100,6 +101,7 @@ func TestScraperNoIOStats(t *testing.T) {

config.Metrics.ElasticsearchIndexOperationsMergeSize.Enabled = true
config.Metrics.ElasticsearchIndexOperationsMergeDocsCount.Enabled = true
config.Metrics.ElasticsearchIndexOperationsMergeCurrent.Enabled = true
config.Metrics.ElasticsearchIndexSegmentsCount.Enabled = true
config.Metrics.ElasticsearchIndexSegmentsSize.Enabled = true
config.Metrics.ElasticsearchIndexSegmentsMemory.Enabled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,18 @@ resourceMetrics:
timeUnixNano: "2000000"
isMonotonic: true
unit: '{operations}'
- description: The number of currently active segment merges
gauge:
dataPoints:
- asInt: "0"
attributes:
- key: aggregation
value:
stringValue: total
startTimeUnixNano: "1000000"
timeUnixNano: "2000000"
name: elasticsearch.index.operations.merge.current
unit: '{merges}'
- description: The total number of documents in merge operations for an index.
name: elasticsearch.index.operations.merge.docs_count
sum:
Expand Down Expand Up @@ -1285,6 +1297,18 @@ resourceMetrics:
timeUnixNano: "2000000"
isMonotonic: true
unit: '{operations}'
- description: The number of currently active segment merges
gauge:
dataPoints:
- asInt: "0"
attributes:
- key: aggregation
value:
stringValue: total
startTimeUnixNano: "1000000"
timeUnixNano: "2000000"
name: elasticsearch.index.operations.merge.current
unit: '{merges}'
- description: The total number of documents in merge operations for an index.
name: elasticsearch.index.operations.merge.docs_count
sum:
Expand Down Expand Up @@ -2298,17 +2322,17 @@ resourceMetrics:
aggregationTemporality: 2
dataPoints:
- asInt: "15746158592"
startTimeUnixNano: "2000000"
timeUnixNano: "1000000"
startTimeUnixNano: "1000000"
timeUnixNano: "2000000"
unit: By
- description: The amount of disk space across all file stores for this node.
name: elasticsearch.node.fs.disk.total
sum:
aggregationTemporality: 2
dataPoints:
- asInt: "67371577344"
startTimeUnixNano: "2000000"
timeUnixNano: "1000000"
startTimeUnixNano: "1000000"
timeUnixNano: "2000000"
unit: By
- description: The number of HTTP connections to the node.
name: elasticsearch.node.http.connections
Expand Down
Loading

0 comments on commit 2027679

Please sign in to comment.