Subject: [prometheus-users] snmp-exporter and crazy custom DISMAN-EXPRESSION-MIB again


Hi all,

Ciscos crazy DISMAN-EXPRESSION-MIB makes a lot of problems to get the right
labels and the right type to the metric.

1. Type in the generated metric is always gauge and I cannot change it,
because before the regex the metric is in the labels and how can I change
the type after the metric was moved to the right place?

2. Why is the first character lost, when the for example
"btob_delete_fail_counter"."btob_delete_fail_counter" is moved to
expExpressionOwner="tob_delete_fail_counter btob_delete_fail_counter"} ?

before the regex:
```snmp_asr_btob_queue{expExpressionOwner="tob_queue\nbtob_queue",snmp_asr_btob_queue="7"}
1``` afterwards the \nb is lost.

3. Is is possible to add a label like the expExpressionComment to the
metric regardless where the index is, just specify the oid and attach it to
the metric? For this custom cisco mibs, based on commands executed on ios
side, it makes sense.

snmwalk:

```
DISMAN-EXPRESSION-MIB::expExpression."rg"."1" = STRING: "1"
DISMAN-EXPRESSION-MIB::expExpression."natMisses"."natMisses" = STRING:
"23949921"
DISMAN-EXPRESSION-MIB::expExpression."btob_queue"."btob_queue" = STRING: "7"
DISMAN-EXPRESSION-MIB::expExpression."btob_delete_fail_counter"."btob_delete_fail_counter"
= STRING: "342634"
DISMAN-EXPRESSION-MIB::expExpressionValueType."rg"."1" = INTEGER:
integer32(4)
DISMAN-EXPRESSION-MIB::expExpressionValueType."natMisses"."natMisses" =
INTEGER: counter64(8)
DISMAN-EXPRESSION-MIB::expExpressionValueType."btob_queue"."btob_queue" =
INTEGER: octetString(6)
DISMAN-EXPRESSION-MIB::expExpressionValueType."btob_delete_fail_counter"."btob_delete_fail_counter"
= INTEGER: counter64(8)
DISMAN-EXPRESSION-MIB::expExpressionComment."rg"."1" = STRING: redundancy
application group 1 state
DISMAN-EXPRESSION-MIB::expExpressionComment."natMisses"."natMisses" =
STRING: Conter containing packet count missing nat entries
DISMAN-EXPRESSION-MIB::expExpressionComment."btob_queue"."btob_queue" =
STRING: btob-HA send queue state
DISMAN-EXPRESSION-MIB::expExpressionComment."btob_delete_fail_counter"."btob_delete_fail_counter"
= STRING: btob-HA delete messege send failures
```

or without lookup:

```
.1.3.6.1.2.1.90.1.2.1.1.3.2.114.103.1.49 = STRING: "1"
.1.3.6.1.2.1.90.1.2.1.1.3.9.110.97.116.77.105.115.115.101.115.9.110.97.116.77.105.115.115.101.115
= STRING: "12349921"
.1.3.6.1.2.1.90.1.2.1.1.3.10.98.116.111.98.95.113.117.101.117.101.10.98.116.111.98.95.113.117.101.117.101
= STRING: "7"
.1.3.6.1.2.1.90.1.2.1.1.3.24.98.116.111.98.95.100.101.108.101.116.101.95.102.97.105.108.95.99.111.117.110.116.101.114.24.98.116.111.98.95.100.101.108.101.116.101.95.102.97.105.108.95.99.111.117.110.116.101.114
= STRING: "342345"
.1.3.6.1.2.1.90.1.2.1.1.4.2.114.103.1.49 = INTEGER: integer32(4)
.1.3.6.1.2.1.90.1.2.1.1.4.9.110.97.116.77.105.115.115.101.115.9.110.97.116.77.105.115.115.101.115
= INTEGER: counter64(8)
.1.3.6.1.2.1.90.1.2.1.1.4.10.98.116.111.98.95.113.117.101.117.101.10.98.116.111.98.95.113.117.101.117.101
= INTEGER: octetString(6)
.1.3.6.1.2.1.90.1.2.1.1.4.24.98.116.111.98.95.100.101.108.101.116.101.95.102.97.105.108.95.99.111.117.110.116.101.114.24.98.116.111.98.95.100.101.108.101.116.101.95.102.97.105.108.95.99.111.117.110.116.101.114
= INTEGER: counter64(8)
.1.3.6.1.2.1.90.1.2.1.1.5.2.114.103.1.49 = STRING: redundancy application
group 1 state
.1.3.6.1.2.1.90.1.2.1.1.5.9.110.97.116.77.105.115.115.101.115.9.110.97.116.77.105.115.115.101.115
= STRING: Conter containing packet count missing nat entries
.1.3.6.1.2.1.90.1.2.1.1.5.10.98.116.111.98.95.113.117.101.117.101.10.98.116.111.98.95.113.117.101.117.101
= STRING: btob-HA send queue state
.1.3.6.1.2.1.90.1.2.1.1.5.24.98.116.111.98.95.100.101.108.101.116.101.95.102.97.105.108.95.99.111.117.110.116.101.114.24.98.116.111.98.95.100.101.108.101.116.101.95.102.97.105.108.95.99.111.117.110.116.101.114
= STRING: btob-HA delete messege send failures
```
snmp.yaml
```
asr:
  walk:
  - 1.3.6.1.2.1.90.1.2.1.1
  metrics:
  - name: snmp_asr_RedundancyGroup
    oid: 1.3.6.1.2.1.90.1.2.1.1.3.2
    type: DisplayString
    help: The expression to be evaluated - 1.3.6.1.2.1.90.1.2.1.1.3
    indexes:
    - labelname: expExpressionOwner
      type: DisplayString
    regex_extracts:
      "":
      - value: '$1'
        regex: ^(?:(.*))$
  - name: snmp_asr_natMisses
    oid: 1.3.6.1.2.1.90.1.2.1.1.3.9
    type: DisplayString
    help: The expression to be evaluated - 1.3.6.1.2.1.90.1.2.1.1.3.9
    indexes:
    - labelname: expExpressionOwner
      type: DisplayString
    regex_extracts:
      "":
      - value: '$1'
        regex: ^(?:(.*))$
  - name: snmp_asr_btob_queue
    oid: 1.3.6.1.2.1.90.1.2.1.1.3.10
    type: DisplayString
    help: The expression to be evaluated - 1.3.6.1.2.1.90.1.2.1.1.3.10
    indexes:
    - labelname: expExpressionOwner
      type: DisplayString
    regex_extracts:
      "":
        - regex: '^(?:(.*))$'
          value: '$1'
          type: OctetString
  - name: snmp_asr_btob_delete_fail_counter
    oid: 1.3.6.1.2.1.90.1.2.1.1.3.24
    type: DisplayString
    help: The expression to be evaluated - 1.3.6.1.2.1.90.1.2.1.1.3.24
    indexes:
    - labelname: expExpressionOwner
      type: DisplayString
    regex_extracts:
      "":
      - value: '$1'
        regex: ^(?:(.*))$
```

output:
```
# HELP snmp_asr_RedundancyGroup The expression to be evaluated -
1.3.6.1.2.1.90.1.2.1.1.3 (regex extracted)
# TYPE snmp_asr_RedundancyGroup gauge
snmp_asr_RedundancyGroup{expExpressionOwner="g 1"} 1
# HELP snmp_asr_btob_delete_fail_counter The expression to be evaluated -
1.3.6.1.2.1.90.1.2.1.1.3.24 (regex extracted)
# TYPE snmp_asr_btob_delete_fail_counter gauge
snmp_asr_btob_delete_fail_counter{expExpressionOwner="tob_delete_fail_counter btob_delete_fail_counter"}
342634
# HELP snmp_asr_btob_queue The expression to be evaluated -
1.3.6.1.2.1.90.1.2.1.1.3.10 (regex extracted)
# TYPE snmp_asr_btob_queue gauge
snmp_asr_btob_queue{expExpressionOwner="tob_queue\nbtob_queue"} 7
# HELP snmp_asr_n