Skip to content

Commit

Permalink
[receiver/elasticsearch]: add query cache metrics on index level (ope…
Browse files Browse the repository at this point in the history
…n-telemetry#14873)

* feat: add query cache metrics on index level

* feat: add cache.size metric

* fix: remove cache name attribute from size metric
  • Loading branch information
aboguszewski-sumo committed Nov 16, 2022
1 parent 0507fac commit dc1f2a7
Show file tree
Hide file tree
Showing 11 changed files with 464 additions and 27 deletions.
16 changes: 16 additions & 0 deletions .chloggen/elasticsearch-query-cache.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: 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 query cache metrics on index level

# 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:
6 changes: 4 additions & 2 deletions receiver/elasticsearchreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ These are the metrics available for this scraper.
| **elasticsearch.cluster.state_queue** | Number of cluster states in queue. | 1 | Sum(Int) | <ul> <li>cluster_state_queue_state</li> </ul> |
| **elasticsearch.cluster.state_update.count** | The number of cluster state update attempts that changed the cluster state since the node started. | 1 | Sum(Int) | <ul> <li>cluster_state_update_state</li> </ul> |
| **elasticsearch.cluster.state_update.time** | The cumulative amount of time updating the cluster state since the node started. | ms | Sum(Int) | <ul> <li>cluster_state_update_state</li> <li>cluster_state_update_type</li> </ul> |
| elasticsearch.index.cache.evictions | The number of evictions from the cache for an index. | {evictions} | Sum(Int) | <ul> <li>cache_name</li> <li>index_aggregation_type</li> </ul> |
| elasticsearch.index.cache.memory.usage | The size in bytes of the cache for an index. | By | Sum(Int) | <ul> <li>cache_name</li> <li>index_aggregation_type</li> </ul> |
| elasticsearch.index.cache.size | The number of elements of the query cache for an index. | 1 | Sum(Int) | <ul> <li>index_aggregation_type</li> </ul> |
| **elasticsearch.index.operations.completed** | The number of operations completed for an index. | {operations} | Sum(Int) | <ul> <li>operation</li> <li>index_aggregation_type</li> </ul> |
| elasticsearch.index.operations.merge.docs_count | The total number of documents in merge operations for an index. | {documents} | Sum(Int) | <ul> <li>index_aggregation_type</li> </ul> |
| elasticsearch.index.operations.merge.size | The total size of merged segments for an index. | By | Sum(Int) | <ul> <li>index_aggregation_type</li> </ul> |
Expand All @@ -38,8 +40,8 @@ These are the metrics available for this scraper.
| **elasticsearch.indexing_pressure.memory.total.replica_rejections** | Number of indexing requests rejected in the replica stage. | 1 | Sum(Int) | <ul> </ul> |
| **elasticsearch.memory.indexing_pressure** | Memory consumed, in bytes, by indexing requests in the specified stage. | By | Sum(Int) | <ul> <li>indexing_pressure_stage</li> </ul> |
| **elasticsearch.node.cache.count** | Total count of query cache misses across all shards assigned to selected nodes. | {count} | Sum(Int) | <ul> <li>query_cache_count_type</li> </ul> |
| **elasticsearch.node.cache.evictions** | The number of evictions from the cache. | {evictions} | Sum(Int) | <ul> <li>cache_name</li> </ul> |
| **elasticsearch.node.cache.memory.usage** | The size in bytes of the cache. | By | Sum(Int) | <ul> <li>cache_name</li> </ul> |
| **elasticsearch.node.cache.evictions** | The number of evictions from the cache on a node. | {evictions} | Sum(Int) | <ul> <li>cache_name</li> </ul> |
| **elasticsearch.node.cache.memory.usage** | The size in bytes of the cache on a node. | By | Sum(Int) | <ul> <li>cache_name</li> </ul> |
| **elasticsearch.node.cluster.connections** | The number of open tcp connections for internal cluster communication. | {connections} | Sum(Int) | <ul> </ul> |
| **elasticsearch.node.cluster.io** | The number of bytes sent and received on the network for internal cluster communication. | By | Sum(Int) | <ul> <li>direction</li> </ul> |
| **elasticsearch.node.disk.io.read** | The total number of kilobytes read across all file stores for this node. | KiBy | Sum(Int) | <ul> </ul> |
Expand Down
135 changes: 133 additions & 2 deletions receiver/elasticsearchreceiver/internal/metadata/generated_metrics.go

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

22 changes: 20 additions & 2 deletions receiver/elasticsearchreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ metrics:
attributes: [circuit_breaker_name]
enabled: true
elasticsearch.node.cache.memory.usage:
description: The size in bytes of the cache.
description: The size in bytes of the cache on a node.
unit: By
sum:
monotonic: false
Expand All @@ -198,7 +198,7 @@ metrics:
attributes: [cache_name]
enabled: true
elasticsearch.node.cache.evictions:
description: The number of evictions from the cache.
description: The number of evictions from the cache on a node.
unit: "{evictions}"
sum:
monotonic: true
Expand Down Expand Up @@ -887,3 +887,21 @@ metrics:
value_type: int
attributes: [cache_name, index_aggregation_type]
enabled: false
elasticsearch.index.cache.size:
description: The number of elements of the query cache for an index.
unit: 1
sum:
monotonic: false
aggregation: cumulative
value_type: int
attributes: [index_aggregation_type]
enabled: false
elasticsearch.index.cache.evictions:
description: The number of evictions from the cache for an index.
unit: "{evictions}"
sum:
monotonic: true
aggregation: cumulative
value_type: int
attributes: [cache_name, index_aggregation_type]
enabled: false
22 changes: 21 additions & 1 deletion receiver/elasticsearchreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func (r *elasticsearchScraper) scrapeIndicesMetrics(ctx context.Context, now pco
indexStats, err := r.client.IndexStats(ctx, r.cfg.Indices)

if err != nil {
errs.AddPartial(18, err)
errs.AddPartial(22, err)
return
}

Expand Down Expand Up @@ -471,6 +471,26 @@ func (r *elasticsearchScraper) scrapeOneIndexMetrics(now pcommon.Timestamp, name
r.mb.RecordElasticsearchIndexCacheMemoryUsageDataPoint(
now, stats.Total.FieldDataCache.MemorySizeInBy, metadata.AttributeCacheNameFielddata, metadata.AttributeIndexAggregationTypeTotal,
)
r.mb.RecordElasticsearchIndexCacheMemoryUsageDataPoint(
now, stats.Total.QueryCache.MemorySizeInBy, metadata.AttributeCacheNameQuery, metadata.AttributeIndexAggregationTypeTotal,
)
r.mb.RecordElasticsearchIndexCacheMemoryUsageDataPoint(
now, stats.Primaries.QueryCache.MemorySizeInBy, metadata.AttributeCacheNameQuery, metadata.AttributeIndexAggregationTypePrimaryShards,
)

r.mb.RecordElasticsearchIndexCacheSizeDataPoint(
now, stats.Primaries.QueryCache.CacheSize, metadata.AttributeIndexAggregationTypePrimaryShards,
)
r.mb.RecordElasticsearchIndexCacheSizeDataPoint(
now, stats.Total.QueryCache.CacheSize, metadata.AttributeIndexAggregationTypeTotal,
)

r.mb.RecordElasticsearchIndexCacheEvictionsDataPoint(
now, stats.Primaries.QueryCache.Evictions, metadata.AttributeCacheNameQuery, metadata.AttributeIndexAggregationTypePrimaryShards,
)
r.mb.RecordElasticsearchIndexCacheEvictionsDataPoint(
now, stats.Total.QueryCache.Evictions, metadata.AttributeCacheNameQuery, metadata.AttributeIndexAggregationTypeTotal,
)

r.mb.EmitForResource(metadata.WithElasticsearchIndexName(name), metadata.WithElasticsearchClusterName(r.clusterName))
}
Loading

0 comments on commit dc1f2a7

Please sign in to comment.