Assigning Label to Output Values

69 views
Skip to first unread message

William Entriken

unread,
Nov 2, 2020, 5:39:37 PM11/2/20
to Prometheus Users
Hello everyone, I have an interesting question regarding labels. So I am trying to pull values with metrics specifically PVC data and pretty much would like to produce a label with the yielded results.
For instance, here is my simple query argument for the PVCs within one of my environments looking for statefulsets that have PVCs with storage utilization that is 40% or higher. Specifically, is there a way to create a label for the value output? This is so when our alerts fire, we could declare a variable which produces accurate info in the alert message itself. Does anyone have any good ideas on this?
Specifically I am trying to produce a {{ $labels.storage }} label, based on the value produced by the expression below:

```kubelet_volume_stats_available_bytes/kubelet_volume_stats_capacity_bytes < .60

Element:
{endpoint="http-metrics",instance="10.xxx.58.210:10255",job="kubelet",metrics_path="/metrics",namespace="{infra}",node="gke-xxx-xxx-xxx-001-stateful-394fxxxx-xxxx",persistentvolumeclaim="prometheus-prometheus-operator-prometheus-db-prometheus-prometheus-operator-prometheus-0",service="prometheus-operator-kubelet"}

Value:
0.505853632940522```

We are also utilizing good ole' Alertmanager: https://prometheus.io/docs/alerting/latest/alertmanager/

Brian Brazil

unread,
Nov 2, 2020, 5:50:54 PM11/2/20
to William Entriken, Prometheus Users
On Mon, 2 Nov 2020 at 22:39, William Entriken <went...@mi9retail.com> wrote:
Hello everyone, I have an interesting question regarding labels. So I am trying to pull values with metrics specifically PVC data and pretty much would like to produce a label with the yielded results.
For instance, here is my simple query argument for the PVCs within one of my environments looking for statefulsets that have PVCs with storage utilization that is 40% or higher. Specifically, is there a way to create a label for the value output? This is so when our alerts fire, we could declare a variable which produces accurate info in the alert message itself. Does anyone have any good ideas on this?
Specifically I am trying to produce a {{ $labels.storage }} label, based on the value produced by the expression below:

A label would be unwise, however you can create a annotation with $value as shown in https://www.robustperception.io/dont-put-the-value-in-alert-labels

Brian
 

```kubelet_volume_stats_available_bytes/kubelet_volume_stats_capacity_bytes < .60

Element:
{endpoint="http-metrics",instance="10.xxx.58.210:10255",job="kubelet",metrics_path="/metrics",namespace="{infra}",node="gke-xxx-xxx-xxx-001-stateful-394fxxxx-xxxx",persistentvolumeclaim="prometheus-prometheus-operator-prometheus-db-prometheus-prometheus-operator-prometheus-0",service="prometheus-operator-kubelet"}

Value:
0.505853632940522```

We are also utilizing good ole' Alertmanager: https://prometheus.io/docs/alerting/latest/alertmanager/

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/ee5d3b3e-71d3-4ef4-8220-d0d018bfe38en%40googlegroups.com.


--

William Entriken

unread,
Nov 3, 2020, 4:41:54 PM11/3/20
to Prometheus Users
Hello Brian,

Thank you for the response, and I am trying out that annotation today!

Reply all
Reply to author
Forward
0 new messages