Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I add OID name in my lables #324

Closed
treemanzhou opened this issue Aug 16, 2018 · 6 comments
Closed

How can I add OID name in my lables #324

treemanzhou opened this issue Aug 16, 2018 · 6 comments

Comments

@treemanzhou
Copy link

treemanzhou commented Aug 16, 2018

Host operating system: output of uname -a

Linux l23-253-100 2.6.32-696.20.1.el6.x86_64 #1 SMP Fri Jan 26 17:51:45 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

snmp_exporter version: output of snmp_exporter -version

snmp_exporter, version 0.11.0 (branch: HEAD, revision: e459171)
build user: root@80735d30559d
build date: 20180530-10:24:52
go version: go1.10.2

What device/snmpwalk OID are you using?

  • name: ifOperStatus
  • name: ifHCInOctets

If this is a new device, please link to the MIB(s).

What did you do that produced an error?

What did you expect to see?

I expect my oid name list in my labels
example as below:
ifOperStatus{hostname="Core1-router",instance="172.10.255.10",job="backbone", ifmib="ifOperStatus"}

What did you see instead?

I 've tried like below , but not work

relabel_configs:
  - source_labels: [__address__]
    target_label: __param_target
  - source_labels: [__param_target]
    target_label: instance
  - target_label: oidname
    replacement: __name__    
@SuperQ
Copy link
Member

SuperQ commented Aug 16, 2018

replacement is a regexp expansion, so you would need to do something like this:

- source_labels: [__name__]
  target_label: oidname

I'm curious as to why you would want this, the metric name can be access in PromQL already with __name__. No additional label is necessary.

@treemanzhou
Copy link
Author

Hi @SuperQ thanks for your reply , I need the name output in the metric ,I tried what you said , but still not work

response:Object
status:"success"
data:Object
resultType:"matrix"
result:Array[1]
0:Object
metric:Object
hostname:"router-1"
ifDescr:"Ethernet1/13"
instance:"10.20.3.2"
job:"router_fabric"
values:Array[2124]

@SuperQ
Copy link
Member

SuperQ commented Aug 16, 2018

Can you explain more about what you're trying to accomplish? What is the use case?

@SuperQ
Copy link
Member

SuperQ commented Aug 16, 2018

This also seems more like a general issue with Prometheus use, not something specific to SNMP.

For usage questions/help, please use our community. On the mailing list, more people are available to potentially respond to your question, and the whole community can benefit from the answers provided.

@SuperQ
Copy link
Member

SuperQ commented Aug 16, 2018

Oh, I noticed one more issue. You are using relabel_configs. This is relabeling for the targets, things that come from service discovery. This comes before the actual scrape so there are no metrics gathered yet.

You're looking for metric_relabel_configs, this comes after the scrape, but before ingestion.

@brian-brazil
Copy link
Contributor

It makes more sense to ask questions like this on the prometheus-users mailing list rather than in a GitHub issue. On the mailing list, more people are available to potentially respond to your question, and the whole community can benefit from the answers provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants