Hi all,
I’m trying to create a custom metric that will count all the requests that contain a specific value for a specific header, let say I want to count all the request that in the header “x-my-header” contains “my-specific-value”.
So I’m creating the objects of type metric
, prometheus
and rule
. The prometheus and rule are simple and expose a metric named myvalue_request_count
. My issue is related to metric
. As I understand, to count all the requests that in “x-my-header” contains “my-specific-value” I have to set the value of 1
whet this condition is true and value of 0
otherwise. But it doesn’t work for me:
...
value: conditional(".*my-specific-value.*".matches(request.headers["x-my-header"]), "1", "0") # count the android users
dimensions:
reporter: conditional((context.reporter.kind | "inbound") == "outbound", "client", "server")
source: source.workload.name | "unknown"
destination: destination.workload.name | "unknown"
monitored_resource_type: '"UNSPECIFIED"'
...
But with this value
the metric with name istio_myvalue_request_count
does not apper in the Prometheus.
If I change the value: "1"
then this metric appears, but all the requests are counted.
What am I doing wrong?