On 07/20/2018 11:27 AM,
anton...@gmail.com wrote:
> *In our environment the current configuration is like what you said, all
> the targets are in our files.*
> *what i want is a function like join in sql.*
> *For example , now we are using snmp monitor our network devices, we can
> only get individual information from each snmp oid , i have a metric
> with the format a{targetip="1.1.1.1",instance='2.2.2.2'} 1*
> *If a.value==0 means the connection between 2.2.2.2 and 1.1.1.1 is
> down, but if i have the cmdb , i can make the alert like " the
> connection between M and N is down",instead of the ip .*
I think there is no generic way to provide a reverse lookup for
something like that.
The following ideas come to mind, however:
Start by storing this mapping data in Prometheus using recording rules
as mentioned in this blog post [1]. You would then have some metric such as
ip2name{ip="1.1.1.1",name="example"} 1
...
Then you can either directly "join" these in your alert expressions as
described in the blog post [1]. In this case, I think, this would be
rather verbose, especially since labels differ (ip, targetip, instance).
Another option -- probably preferrable -- would be to run a sub-query in
your alert template [2].
Does that help?
Kind regards,
Christian
[1]
https://www.robustperception.io/using-time-series-as-alert-thresholds
[2]
https://prometheus.io/docs/prometheus/latest/configuration/template_reference/#queries