Try adding a new label using label_replace
<https://prometheus.io/docs/prometheus/latest/querying/functions/#label_replace>,
e.g.
label_replace(ifHCInOctets, "vid", "$1", "ifAlias", ".*@(.+)@.*")
When that works, you can start using it in a subexpression:
sum by (vid) ( label_replace(rate(ifHCInOctets[10m]), "vid", "$1",
"ifAlias", ".*@(.+)@.*") )
If you're doing this a lot, you might want to add the new label at scrape
time using a metric rewriting rule, or generate some new timeseries using a
recording rule.
On Saturday, 22 January 2022 at 06:59:38 UTC [email protected] wrote:
> Hello Everyone,
>
> How to sum according to "@...@" on ifAlias which changes dynamically in
> addition to this ifAlias are not totally same but @..@ are same on ifAlias.
> if they are same, I want to aggregate them. I tried to query below which
> is not so dynamic.
>
> sum by (instance)
> (rate(ifHCInOctets{ifAlias=~"^QinQ_.*020000026586.*_NNI.*"}[10m]) * 8) and
> on(instance) sysName{sysName =~ ".*$name.*"}
>
> How to make dynamic like if they x combine them, if they are y combine
> them, etc.
>
> {ifAlias="QinQ_BTS_B4965_ABIS@020000026586@||TT/ME-200-10000||_NNI_BKD",
> ifDescr="GigabitEthernet3/1/0.2068", ifIndex="494", instance="10.85.7.2",
> job="ptn"}
> {ifAlias="QinQ_NodeB_B4965@020000026586@||TT/ME-200-10000||_NNI_BKD",
> ifDescr="GigabitEthernet3/1/0.1088", ifIndex="495", instance="10.85.7.2",
> job="ptn"}
> {ifAlias="QinQ_eNodeB_B4965_OAM@020000026586@||TT/ME-200-10000||_NNI_BKD",
> ifDescr="GigabitEthernet3/1/0.3662", ifIndex="493", instance="10.85.7.2",
> job="ptn"}
> {ifAlias="QinQ_eNodeB_B4965_S1_X2@020000026586@||TT/ME-200-10000||_NNI_BKD",
> ifDescr="GigabitEthernet3/1/0.3661", ifIndex="492", instance="10.85.7.2",
> job="ptn"}
>
> {ifAlias="QinQ_BTS_C1623_ABIS@020000026587@||TT/ME-200-10000||_NNI_BKD",
> ifDescr="GigabitEthernet3/1/0.2067", ifIndex="496", instance="10.85.7.2",
> job="ptn"}
> {ifAlias="QinQ_NodeB_C1623@020000026587@||TT/ME-200-10000||_NNI_BKD",
> ifDescr="GigabitEthernet3/1/0.1098", ifIndex="497", instance="10.85.7.2",
> job="ptn"}
> {ifAlias="QinQ_eNodeB_C1623_OAM@020000026587@||TT/ME-200-10000||_NNI_BKD",
> ifDescr="GigabitEthernet3/1/0.3663", ifIndex="498", instance="10.85.7.2",
> job="ptn"}
> {ifAlias="QinQ_eNodeB_C1623_S1_X2@020000026587@||TT/ME-200-10000||_NNI_BKD",
> ifDescr="GigabitEthernet3/1/0.3664", ifIndex="499", instance="10.85.7.2",
> job="ptn"}
>
> Thanks.
>
--
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/34b94b9e-915d-47ea-8d97-3d0e5f726d7dn%40googlegroups.com.