I've just checked, and snmp_exporter will happily start even if it can't 
find snmp.yml. strace shows:

newfstatat(AT_FDCWD, "snmp.yml", 0xc0001b2ed8, AT_SYMLINK_NOFOLLOW) = -1 
ENOENT (No such file or directory)

(but it continues to run, and doesn't log any error). This feels like a bug 
to me, as it will lead to confusing behaviour which is quite possibly 
what's happening to you. Whereas Prometheus complains and refuses to start:

ts=2025-06-26T15:49:29.540Z caller=main.go:537 level=error msg="Error 
loading config (--config.file=prometheus.yml)" 
file=/root/zzz/prometheus.yml err="open prometheus.yml: no such file or 
directory"

On Thursday, 26 June 2025 at 16:43:04 UTC+1 Brian Candler wrote:

> On Thursday, 26 June 2025 at 15:42:36 UTC+1 Joel Djojotaroeno wrote:
>
> I have two prometheus.yml files:
> /home/rpbgintern2/prometheus.yml
> /etc/prometheus/prometheus.yml
>
> And two snmp.yml files:
> /home/rpbgintern2/snmp_exporter-0.26.0.linux-amd64/snmp.yml
> /home/rpbgintern2/snmp/snmp.yml
>
> I don't know if multiple yml files are causing this error. 
>
>
> No. But you do need to work out which is being used.
>
> This depends on how you are starting the services. Are you using systemd 
> services perhaps?
>
> If you're not sure, then use
> ps auxwww | grep prometheus
> ps auxwww | grep snmp_exporter
> to see what flags you're running them with.
>
> For prometheus, the config file is specified by the --config.file 
> argument. If you don't specify it, it will read "prometheus.yml" in 
> whatever the current working directory is when prometheus is started.
>
> snmp_exporter also has a --config.file argument; I believe it defaults to 
> "snmp.yml" in the current working directory.  It can be used with a 
> wildcard, e.g. '--config.file=/etc/prometheus/snmp.d/*.yml'.  
> This is very useful because you can provide multiple files: the supplied 
> snmp.yml, and then a separate file (say "auth.yml") with just your 
> site-specific authentication parameters. For example:
>
> auths:
>   test_v2:
>     version: 2
>     community: Testing123
>
>   test_v3:
>     version: 3
>     security_level: authNoPriv
>     username: admin
>     auth_protocol: SHA
>     password: Testing123
>
>   test_v3_priv:
>     version: 3
>     security_level: authPriv
>     username: admin
>     auth_protocol: SHA
>     password: Testing123
>     priv_protocol: AES
>     priv_password: VerySecret
>
> If you're polling snmp_exporter with parameter public_v1, then this auth 
> needs to be defined. The supplied snmp.yml does define this, so perhaps 
> your snmp_exporter is not picking up *any* configuration files? That will 
> be down to the --config.file parameter you may or may not be passing.
>  
> Either that, or there's a typo somewhere. I note that your error message 
> complains about "public_v1_'' with a trailing underscore.
>

-- 
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 visit 
https://groups.google.com/d/msgid/prometheus-users/dd3ef3e6-e4f2-446b-9843-14844b74c8f2n%40googlegroups.com.

Reply via email to