Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[receiver/elasticsearch]: Add endpoint resource attribute #14774

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .chloggen/elasticsearch-receiver-add-host-attr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
change_type: breaking
component: elasticsearchreceiver
note: Add resource attribute with queried endpoint
issues: [14635]

1 change: 1 addition & 0 deletions receiver/elasticsearchreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ metrics:
| Name | Description | Type |
| ---- | ----------- | ---- |
| elasticsearch.cluster.name | The name of the elasticsearch cluster. | String |
| elasticsearch.endpoint | Endpoint of the queried elasticsearch node. | String |
| elasticsearch.index.name | The name of the elasticsearch index. | String |
| elasticsearch.node.name | The name of the elasticsearch node. | String |

Expand Down

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

3 changes: 3 additions & 0 deletions receiver/elasticsearchreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ resource_attributes:
elasticsearch.node.name:
description: The name of the elasticsearch node.
type: string
elasticsearch.endpoint:
description: Endpoint of the queried elasticsearch node.
type: string
Comment on lines +10 to +12
Copy link
Member Author

@aboguszewski-sumo aboguszewski-sumo Oct 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not decide to go for elasticsearch.node.endpoint, because we query only one node, but the results can refer to different nodes and this would be a misleading hint that both elasticsearch.node.endpoint and elasticsearch.node.name refer to the same node, while they would not.

elasticsearch.index.name:
description: The name of the elasticsearch index.
type: string
Expand Down
18 changes: 14 additions & 4 deletions receiver/elasticsearchreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,11 @@ func (r *elasticsearchScraper) scrapeNodeMetrics(ctx context.Context, now pcommo
r.mb.RecordElasticsearchNodeScriptCompilationsDataPoint(now, info.Script.Compilations)
r.mb.RecordElasticsearchNodeScriptCompilationLimitTriggeredDataPoint(now, info.Script.CompilationLimitTriggered)

r.mb.EmitForResource(metadata.WithElasticsearchClusterName(nodeStats.ClusterName),
metadata.WithElasticsearchNodeName(info.Name))
r.mb.EmitForResource(
metadata.WithElasticsearchClusterName(nodeStats.ClusterName),
metadata.WithElasticsearchNodeName(info.Name),
metadata.WithElasticsearchEndpoint(r.cfg.Endpoint),
)
}
}

Expand Down Expand Up @@ -366,7 +369,10 @@ func (r *elasticsearchScraper) scrapeClusterMetrics(ctx context.Context, now pco
errs.AddPartial(1, fmt.Errorf("health status %s: %w", clusterHealth.Status, errUnknownClusterStatus))
}

r.mb.EmitForResource(metadata.WithElasticsearchClusterName(clusterHealth.ClusterName))
r.mb.EmitForResource(
metadata.WithElasticsearchClusterName(clusterHealth.ClusterName),
metadata.WithElasticsearchEndpoint(r.cfg.Endpoint),
)
}

func (r *elasticsearchScraper) scrapeIndicesMetrics(ctx context.Context, now pcommon.Timestamp, errs *scrapererror.ScrapeErrors) {
Expand Down Expand Up @@ -404,5 +410,9 @@ func (r *elasticsearchScraper) scrapeOneIndexMetrics(now pcommon.Timestamp, name
now, stats.Total.SearchOperations.QueryTimeInMs, metadata.AttributeOperationQuery, metadata.AttributeIndexAggregationTypeTotal,
)

r.mb.EmitForResource(metadata.WithElasticsearchIndexName(name), metadata.WithElasticsearchClusterName(r.clusterName))
r.mb.EmitForResource(
metadata.WithElasticsearchIndexName(name),
metadata.WithElasticsearchClusterName(r.clusterName),
metadata.WithElasticsearchEndpoint(r.cfg.Endpoint),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
"value": {
"stringValue": "917e13e55eed"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9200"
}
}
]
},
Expand Down Expand Up @@ -2198,6 +2204,12 @@
"value": {
"stringValue": "docker-cluster"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9200"
}
}
]
},
Expand Down Expand Up @@ -2324,6 +2336,12 @@
"value": {
"stringValue": "docker-cluster"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9200"
}
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
"value": {
"stringValue": "917e13e55eed"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9200"
}
}
]
},
Expand Down Expand Up @@ -2192,6 +2198,12 @@
"value": {
"stringValue": "docker-cluster"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9200"
}
}
]
},
Expand Down Expand Up @@ -2391,6 +2403,12 @@
"value": {
"stringValue": "docker-cluster"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9200"
}
}
]
},
Expand Down Expand Up @@ -2517,6 +2535,12 @@
"value": {
"stringValue": "docker-cluster"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9200"
}
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
"value": {
"stringValue": "917e13e55eed"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9200"
}
}
]
},
Expand Down Expand Up @@ -2187,6 +2193,12 @@
"value": {
"stringValue": "docker-cluster"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9200"
}
}
]
},
Expand Down Expand Up @@ -2386,6 +2398,12 @@
"value": {
"stringValue": "docker-cluster"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9200"
}
}
]
},
Expand Down Expand Up @@ -2512,6 +2530,12 @@
"value": {
"stringValue": "docker-cluster"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9200"
}
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
"value": {
"stringValue": "docker-cluster"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9200"
}
}
]
},
Expand Down Expand Up @@ -207,6 +213,12 @@
"value": {
"stringValue": "docker-cluster"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9200"
}
}
]
},
Expand Down Expand Up @@ -333,6 +345,12 @@
"value": {
"stringValue": "docker-cluster"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9200"
}
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
"value": {
"stringValue": "085693db869f"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9300"
}
}
]
},
Expand Down Expand Up @@ -5132,6 +5138,12 @@
"value": {
"stringValue": "docker-cluster"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9300"
}
}
]
},
Expand Down Expand Up @@ -5295,6 +5307,12 @@
"value": {
"stringValue": ".geoip_databases"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9300"
}
}
]
},
Expand Down Expand Up @@ -5415,6 +5433,12 @@
"value": {
"stringValue": "_all"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9300"
}
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
"value": {
"stringValue": "a3fd1f595e8a"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9200"
}
}
]
},
Expand Down Expand Up @@ -3883,6 +3889,12 @@
"value": {
"stringValue": "docker-cluster"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9200"
}
}
]
},
Expand Down Expand Up @@ -4076,6 +4088,12 @@
"value": {
"stringValue": ".geoip_databases"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9200"
}
}
]
},
Expand Down Expand Up @@ -4196,6 +4214,12 @@
"value": {
"stringValue": "_all"
}
},
{
"key": "elasticsearch.endpoint",
"value": {
"stringValue": "http://localhost:9200"
}
}
]
},
Expand Down