The "result" of the expression is available as {{ $value }}, and there are
functions to convert this into a more human-readable value.
See
https://prometheus.io/docs/prometheus/latest/configuration/template_reference/
Examples:
expr: windows_logical_disk_free_bytes{volume="C:"} /
windows_logical_disk_size_bytes
annotations:
description: "Low free disk space: {{ $value | humanizePercentage }}"
expr: windows_logical_disk_free_bytes{volume="C:"} < 1000000000
annotations:
description: "Low free disk space: {{ $value | humanize }}" # or
humanize1024: depends if you want Gigabytes or
Gibibytes. https://en.wikipedia.org/wiki/Gigabyte
If you want to do the threshold based on percent, but report the absolute
value, I would use something like this (untested):
expr: windows_logical_disk_free_bytes and
(windows_logical_disk_free_bytes{volume="C:"} /
windows_logical_disk_size_bytes < 0.1)
annotations:
description: "Low free disk space: {{ $value | humanize }}"
I believe it's also possible to embed a completely separate query in a
template (to look up a separate value to include in the annotations), but
I've never done it, and can't find any examples.
Aside: I find these sort of static alerts annoying. Sometimes a filesystem
has 8% disk free space and that's a good and normal situation for it to be
in. Therefore, either you're lost in a sea of unimportant repeating alerts,
or you're jumping through hoops for setting separate static thresholds per
filesystem.
https://groups.google.com/g/prometheus-users/c/wHLxUPtrb-A/m/idIcdJIrBgAJ
Another approach you could consider:
https://groups.google.com/g/prometheus-users/c/0ncUqLm0LhU/m/mAiwaADXAgAJ
This looks at how quickly the filesystem is filling up, and tells you how
long before it expects to be full.
On Wednesday, 10 May 2023 at 09:23:27 UTC+1 Kolja Krückmann wrote:
> Small correction here:
>
> I want to have the expression
> "windows_logical_disk_free_bytes{volume="C:"}/1000/1000/1000" (if this is
> the actual GB of free disk space (or do I need to device by 1024?)) in my
> alerting mail. And not as above the percentage.
>
> Kolja Krückmann schrieb am Mittwoch, 10. Mai 2023 um 10:20:53 UTC+2:
>
>> Hi y'all
>>
>> I'm looking for a possibility to add the "result" of an expression to the
>> alerting description.
>> My expression is to alert when the c:\ Drive is below 10%. Now I want to
>> add the actual value of the expression:
>> ((windows_logical_disk_free_bytes{volume="C:"} /
>> windows_logical_disk_size_bytes) * 100) <= 10
>> in the alerting mail. Is this somehow possible so that the free size is
>> within the mail?
>>
>> Kind regards
>>
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-users/5d696b21-549b-4539-8b52-c4433df71bedn%40googlegroups.com.