Reputation: 6003
In the following sample rule, What's the meaning for {{ with query "time()" }}{{ . | first | value | humanizeTimestamp }}{{ end }}? I search the prometheus doc, but can't find the definition.
- alert: SCPIngressTrafficRateAboveMajorThreshold
annotations:
timestamp: ' {{ with query "time()" }}{{ . | first | value | humanizeTimestamp }}{{ end }} '
description: 'Ingress Traffic Rate at locality: {{$labels.ocscp_locality}} is above major threshold (i.e. 1400 mps)'
summary: 'namespace: {{$labels.kubernetes_namespace}}, podname: {{$labels.kubernetes_pod_name}}, timestamp: {{ with query "time()" }}{{ . | first | value | humanizeTimestamp }}{{ end }}: Current Ingress Traffic Rate is {{ $value | printf "%.2f" }} mps which is above 80 Percent of Max MPS(1700)'
# Provide app and kubernetes_namespace of scp deployed
Upvotes: 0
Views: 719
Reputation: 22441
Basically, it will show the timestamp in a more readable format.
You can see more details about the Prometheus functions in the TEMPLATE REFERENCE section in the Prometheus documentation.
There're good examples in the TEMPLATE EXAMPLES section in the Prometheus documentation.
Upvotes: 1