Update readme to include json-eval

Signed-off-by: Angel Alonso <angel.alonso@automattic.com>
This commit is contained in:
Angel Alonso
2025-01-29 13:23:28 +00:00
parent 5da796fc9a
commit 876074ab75

View File

@ -116,6 +116,7 @@ metadata:
annotations: annotations:
# metric-config.<metricType>.<metricName>.<collectorType>/<configKey> # metric-config.<metricType>.<metricName>.<collectorType>/<configKey>
metric-config.pods.requests-per-second.json-path/json-key: "$.http_server.rps" metric-config.pods.requests-per-second.json-path/json-key: "$.http_server.rps"
metric-config.pods.requests-per-second.json-path/json-eval: "ceil($['active processes'] / $['total processes'] * 100)" # cannot use both json-eval and json-key
metric-config.pods.requests-per-second.json-path/path: /metrics metric-config.pods.requests-per-second.json-path/path: /metrics
metric-config.pods.requests-per-second.json-path/port: "9090" metric-config.pods.requests-per-second.json-path/port: "9090"
metric-config.pods.requests-per-second.json-path/scheme: "https" metric-config.pods.requests-per-second.json-path/scheme: "https"
@ -158,6 +159,10 @@ The json-path query support depends on the
See the README for possible queries. It's expected that the metric you query See the README for possible queries. It's expected that the metric you query
returns something that can be turned into a `float64`. returns something that can be turned into a `float64`.
The `json-eval` configuration option allows for more complex calculations to be
performed on the extracted metric. The `json-eval` expression is evaluated using
ajson's script engine.
The other configuration options `path`, `port` and `scheme` specify where the metrics The other configuration options `path`, `port` and `scheme` specify where the metrics
endpoint is exposed on the pod. The `path` and `port` options do not have default values endpoint is exposed on the pod. The `path` and `port` options do not have default values
so they must be defined. The `scheme` is optional and defaults to `http`. so they must be defined. The `scheme` is optional and defaults to `http`.
@ -825,6 +830,7 @@ metadata:
annotations: annotations:
# metric-config.<metricType>.<metricName>.<collectorType>/<configKey> # metric-config.<metricType>.<metricName>.<collectorType>/<configKey>
metric-config.external.unique-metric-name.json-path/json-key: "$.some-metric.value" metric-config.external.unique-metric-name.json-path/json-key: "$.some-metric.value"
metric-config.external.unique-metric-name.json-path/json-eval: ceil($['active processes'] / $['total processes'] * 100) # cannot use both json-eval and json-key
metric-config.external.unique-metric-name.json-path/endpoint: "http://metric-source.app-namespace:8080/metrics" metric-config.external.unique-metric-name.json-path/endpoint: "http://metric-source.app-namespace:8080/metrics"
metric-config.external.unique-metric-name.json-path/aggregator: "max" metric-config.external.unique-metric-name.json-path/aggregator: "max"
metric-config.external.unique-metric-name.json-path/interval: "60s" # optional metric-config.external.unique-metric-name.json-path/interval: "60s" # optional
@ -852,6 +858,8 @@ The HTTP collector similar to the Pod Metrics collector. The following
configuration values are supported: configuration values are supported:
- `json-key` to specify the JSON path of the metric to be queried - `json-key` to specify the JSON path of the metric to be queried
- `json-eval` to specify an evaluate string to [evaluate on the script engine](https://github.com/spyzhov/ajson?tab=readme-ov-file#script-engine),
cannot be used in conjunction with `json-key`
- `endpoint` the fully formed path to query for the metric. In the above example a Kubernetes _Service_ - `endpoint` the fully formed path to query for the metric. In the above example a Kubernetes _Service_
in the namespace `app-namespace` is called. in the namespace `app-namespace` is called.
- `aggregator` is only required if the metric is an array of values and specifies how the values - `aggregator` is only required if the metric is an array of values and specifies how the values