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

input.snmp 值映射 #919

Open
luweijun1992 opened this issue May 12, 2024 · 6 comments
Open

input.snmp 值映射 #919

luweijun1992 opened this issue May 12, 2024 · 6 comments

Comments

@luweijun1992
Copy link

luweijun1992 commented May 12, 2024

当前插件支持的是将字符映射成数字

[[processor_enum]]
  metrics = ["*status"]
  [processor_enum.value_mappings]
    up = 1
    down = 0

但是有的场景是想要做到数值映射成字符,毕竟数值对应的意思还需要查文档,如果直接显示对应的字符就更清晰明了。
举例:
光模块类型,当前snmp读取到的是数字,那就需要翻译文档看每个数字对应的状态。

hwEntityOpticalMode 光模块的单模/多模模式 {notSupported(1),singleMode(2),multiMode5(3),multiMode6(4),noValue(5),gpsMode(6),copperMode(7),singleAndmultiMode(8)}

是不是可以让插件在采集的时候就把这个转换处理完成。
前提是这个oid作为标签而不是指标。

[[instances.table.field]]
    oid = ".1.3.6.1.4.1.2011.5.25.31.1.1.3.1.1"
    name = "hwEntityOpticalMode"
    is_tag = true
    [[instances.table.field.value_mappings]]
        1 = notSupported
        2 = singleMode
        3 = multiMode5
        4 = multiMode6
        5 = noValue
        6 = gpsMode
        7 = copperMode
        8 = singleAndmultiMode
@kongfei605
Copy link
Collaborator

kongfei605 commented May 14, 2024

conversion=“enum” 

translator 设置为 gosmi ,可以自动转换enum

#924

v0.3.64

@luweijun1992
Copy link
Author

conversion=“enum” 

translator 设置为 gosmi ,可以自动转换enum

#924

v0.3.64

能投提供个配置模板参考下,谢谢。

@kongfei605
Copy link
Collaborator

translator=gosmi
path=["axxxx", "bxxxx"] # 所有mib依赖文件
……
oid="xxxx"
conversion="enum"

@luweijun1992
Copy link
Author

translator=gosmi
path=["axxxx", "bxxxx"] # 所有mib依赖文件
……
oid="xxxx"
conversion="enum"

所以oid一定要文本型,不能数字型?
且这个值映射的信息只能是mib文件中已经定义好的,不能是像我上面自己定义的?

@kongfei605
Copy link
Collaborator

对,依赖mib,不能自定义

@kongfei605
Copy link
Collaborator

自定义映射的方案,这块我们再讨论下

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

2 participants