Thanks,

The reason the metrics have the same name as the label is because in order 
to bring the value in from the SNMP exporter as a lablel, you have to set 
the type as DisplayString. As from what I have read, doing a 'join' would 
not allow you yo get the value of the metric in as a label value.

I managed to get it working with:

`ltmPoolMbrStatusAvailState * 
on(instance,ltmPoolMbrStatusNodeName,ltmPoolMbrStatusPoolName,ltmPoolMbrStatusPort)
 
group_right(ltmPoolMbrStatusAvailState) ltmPoolMbrStatusEnabledState)`

However, from doing that I have realised that what I am trying to achieve 
will require the metric to be pre-existing rather than using the Query to 
build the metric.

The eventual aim was to be able to report on F5 pools that do not have any 
nodes left in the pool to be able to service a request, the nodes can 
either be disabled or unavailable or both.

Initially I was using:

`count by (instance, ltmPoolMbrStatusPoolName) 
(ltmPoolMbrStatusAvailState{ltmPoolMbrStatusNodeName!~".*MAINT.*"})` - This 
gets me the total pool members minus any maint servers no matter the 
availability

and

`count by (instance, ltmPoolMbrStatusPoolName) 
(ltmPoolMbrStatusAvailState{ltmPoolMbrStatusNodeName!~".*MAINT.*"}!= 1)` - 
This gets me the total pool members that are NOT available. Not a value of 
1. With 1 meaning available.

If I put these together like:


`count by (instance, ltmPoolMbrStatusPoolName) 
(ltmPoolMbrStatusAvailState{ltmPoolMbrStatusNodeName!~".*MAINT.*"}) - count 
by (instance, ltmPoolMbrStatusPoolName) 
(ltmPoolMbrStatusAvailState{ltmPoolMbrStatusNodeName!~".*MAINT.*"}!= 1) == 
0`

And checked if the value equals 0, that would tell me that the pool has no 
members that are AVAILABLE. However, I would not know if any nodes in the 
pool had been user disabled, so I wouldn't be able to trust the metric. If 
the value was 1, I would not know if that 1 node was disabled for example.


What I was wanting to achieve by having the values for each in a single 
metric was what I could do this:

1. `count by (instance, ltmPoolMbrStatusPoolName) 
(ltmPoolMbrStatusAvailState{ltmPoolMbrStatusNodeName!~".*MAINT.*"})` - This 
gets me the total pool members minus maint servers no matter the 
availability

and

2. `count by (instance, ltmPoolMbrStatusPoolName) 
(ltmPoolMbrStatusAvailState{ltmPoolMbrStatusNodeName!~".*MAINT.*",ltmPoolMbrStatusAvailState="1",ltmPoolMbrStatusEnabledState!="1"})`
 
- This gets me the total pool members that ARE available AND are NOT 
enabled. Meaning they are non functional

and 

3. `count by (instance, ltmPoolMbrStatusPoolName) 
(ltmPoolMbrStatusAvailState{ltmPoolMbrStatusNodeName!~".*MAINT.*",ltmPoolMbrStatusAvailState!="1",ltmPoolMbrStatusEnabledState="1"})`
 
- This gets me the total pool members that are NOT available AND are 
enabled. Meaning they are non functional

and 

4. `count by (instance, ltmPoolMbrStatusPoolName) 
(ltmPoolMbrStatusAvailState{ltmPoolMbrStatusNodeName!~".*MAINT.*",ltmPoolMbrStatusAvailState!="1",ltmPoolMbrStatusEnabledState!="1"})`
 
- This gets me the total pool members that are NOT available AND are NOT 
enabled. Meaning they are non functional

Then I could put that together and do `1 - 2 - 3 - 4 == 0`. If the final 
result was 0 then I could be pretty certain that no nodes are available to 
handle requests.

My issue with the above is that I don't have the 
`ltmPoolMbrStatusAvailState` metric with both the 
`ltmPoolMbrStatusAvailState` and `ltmPoolMbrStatusEnabledState` label 
values. Im not sure how I would manage to get the merged metric in this way.

The other issue is that queries 2,3 and 4 will not return a 0 value if for 
example on number 2 there are no members that ARE available AND are NOT 
enabled, so no value is returned, im not sure how that would be handled in 
the maths operation as it would likely be "no data" rather than 0.

Hope that makes sense! Its quite the mess.

Thanks
Nick

On Tuesday, 7 March 2023 at 12:53:05 UTC Brian Candler wrote:

> Something like:
>
> ltmPoolMbrStatusAvailState * 
> on(instance,ltmPoolMbrStatusNodeName,ltmPoolMbrStatusPoolName,ltmPoolMbrStatusPort)
> group_left(ltmPoolMbrStatusEnabledState) ltmPoolMbrStatusEnabledState
>
> (Slightly confusing that "ltmPoolMbrStatusEnabledState" is both a label 
> name, and a metric name)
>

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/330fc158-3ee3-415d-aef8-f7ff86461ca0n%40googlegroups.com.

Reply via email to