Hello,
Anyone using Alloy with SNMP Exporter that can offer some help here.
So I have been using SNMP Exporter for ‘if_mib’ network switch information against our Cisco switches, it’s perfect. Recently I added a new module (in the generator.yml) to walk against these same switches for CPU and Memory this time, like this below and generated a new snmp.yml:
cisco_v2:
version: 2
community: public
modules:
# Default IF-MIB interfaces table with ifIndex.
if_mib:
walk: [sysName, sysUpTime, interfaces, ifXTable]
lookups:
- source_indexes: [ifIndex]
lookup: ifAlias
- source_indexes: [ifIndex]
# Uis OID to avoid conflict with PaloAlto PAN-COMMON-MIB.
lookup: 1.3.6.1.2.1.2.2.1.2 # ifDescr
- source_indexes: [ifIndex]
# Use OID to avoid conflict with Netscaler NS-ROOT-MIB.
lookup: 1.3.6.1.2.1.31.1.1.1.1 # ifName
overrides:
ifAlias:
ignore: true # Lookup metric
ifDescr:
ignore: true # Lookup metric
ifName:
ignore: true # Lookup metric
ifType:
type: EnumAsInfo
sysName:
# ignore: true
type: DisplayString
cisco_metrics:
walk:
- cpmCPUTotalTable
- ciscoMemoryPoolTable
The problem I have is how I can’t use this new module called ‘cisco_metrics’ against the same switches. I use Alloy you see like this below. It looks for a switches.json file currently so it uses the ‘if_mib’ module only:
Here is part of switch.json:
{
"labels": {
"auth": "cisco_v2",
"module": "if_mib",
"name": "E06-SW1"
},
"targets": [
"10.10.5.6"
]
},
{
"labels": {
"auth": "cisco_v2",
"module": "if_mib",
"name": "E06-SW2"
},
"targets": [
"10.10.5.7"
]
}
You can see the module ‘if_mib’ I scrape. I don’t think I can add in another module here like ‘cisco_metrics’?
Here is my docker compose section for Alloy:
alloy:
image: grafana/alloy:latest
volumes:
- /opt/mydocker/exporter/config/config.alloy:/etc/alloy/config.alloy
- /opt/mydocker/exporter/config/snmp.yml:/etc/snmp.yml
- /opt/mydocker/exporter/config/switches.json:/etc/switches.json
Here is the config.alloy
discovery.file "integrations_snmp" {
files = ["/etc/switches.json"]
}
prometheus.exporter.snmp "integrations_snmp" {
config_file = "/etc/snmp.yml"
targets = discovery.file.integrations_snmp.targets
}
discovery.relabel "integrations_snmp" {
targets = prometheus.exporter.snmp.integrations_snmp.targets
rule {
source_labels = ["job"]
regex = "(^.*snmp)\\/(.*)"
target_label = "job_snmp"
}
rule {
source_labels = ["job"]
regex = "(^.*snmp)\\/(.*)"
target_label = "snmp_target"
replacement = "$2"
}
rule {
source_labels = ["instance"]
target_label = "instance"
replacement = "cisco_snmp_agent"
}
}
prometheus.scrape "integrations_snmp" {
scrape_timeout = "30s"
targets = discovery.relabel.integrations_snmp.output
forward_to = [prometheus.remote_write.integrations_snmp.receiver]
job_name = "integrations/snmp"
clustering {
enabled = true
}
}
prometheus.remote_write "integrations_snmp" {
endpoint {
url = "http://10.11.5.2:9090/api/v1/write"
queue_config { }
metadata_config { }
}
}
As you can see it also points to switches.json and snmp.yml
I’m probably over thinking how to solve it. Can I combine the module section to include ‘if_mib’ and ‘cisco_metrics’ instead? If so how would that be formatted to include both?
Or
Use the 1 snmp.yml with 2 module sections and use a switches2.yml with the “cisco_switches” module in there, then add this new file to Alloy in docker compose and create a new section within config.alloy?
Thanks