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

Telegraf not able to process datetime received from SNMP Input plugin #12456

Closed
Dhyanesh97 opened this issue Jan 4, 2023 · 7 comments · Fixed by #15439
Closed

Telegraf not able to process datetime received from SNMP Input plugin #12456

Dhyanesh97 opened this issue Jan 4, 2023 · 7 comments · Fixed by #15439
Labels
bug unexpected problem or unintended behavior support Telegraf questions, may be directed to community site or slack

Comments

@Dhyanesh97
Copy link

Relevant telegraf.conf

[[inputs.snmp]]
   agents = ["udp://IP:Port"]
   interval = "60s"
   timeout = "30s"
   retries = 3
   version = 2
   community = "public"
   max_repetitions = 30
   name = "snmp"

 
  [[inputs.snmp.table]]
    name = "alarmsTable"
    oid = ".1.3.6.1.4.1.331.1.2.1.1.2.6"


[[processors.starlark]]
  source = '''
def apply(metric):
  if metric.name == "table":
    print(metric)

  return metric
'''

Logs from Telegraf

# Telegraf Logs
table,agent_host=IP,eventDateTime="�0+",eID=8060i 1672842224000000000
table,agent_host=IP,eventDateTime="�88+",eID=8063i 1672842224000000000

# Telegraf Logs from starlark plugin after print
"eventDateTime": "\a\xe6\x04\v\x15,2\x00+\x00\x00"
"eventDateTime": "\a\xe6\x05\x1f\x1788\x00+\x00\x00"
"eventDateTime": "\a\xe4\x04\x0f\x13\x130\x00+\x00\x00"

System info

Telegraf:1.24, Ubuntu 20.04, Docker version 20.10.18

Docker

No response

Steps to reproduce

  1. Configure SNMP input plugin to fetch the data.
  2. Date format from source end look like 1992-5-26,13:30:15.0,-4:0
  3. Convert this data into string or date format while inserting into influxdb.
    ...

Expected behavior

Data should be inserted in datetime or string format in influxdb

Actual behavior

It is treating it as junk character which we are not able to handle properly.

Additional info

Date format from source end look like 1992-5-26,13:30:15.0,-4:0

A date-time specification.

field octets contents range


1 1-2 year 0..65536
2 3 month 1..12
3 4 day 1..31
4 5 hour 0..23
5 6 minutes 0..59
6 7 seconds 0..60
(use 60 for leap-second)
7 8 deci-seconds 0..9
8 9 direction from UTC '+' / '-'
9 10 hours from UTC 0..11
10 11 minutes from UTC 0..59

For example, Tuesday May 26, 1992 at 1:30:15 PM EDT would be
displayed as:

            1992-5-26,13:30:15.0,-4:0

Note that if only local time is known, then timezone
information (fields 8-10) is not present.

@Dhyanesh97 Dhyanesh97 added the bug unexpected problem or unintended behavior label Jan 4, 2023
@powersj
Copy link
Contributor

powersj commented Jan 4, 2023

Telegraf is translating those values to a string, which is why it comes out looking strange. If you need to parse these values according to that spec then you might try using the starlark processor to read each part and produce the datetime string as you expect.

@powersj powersj added the support Telegraf questions, may be directed to community site or slack label Jan 4, 2023
@telegraf-tiger
Copy link
Contributor

telegraf-tiger bot commented Jan 4, 2023

Hello! I recommend posting this question in our Community Slack or Community Page, we have a lot of talented community members there who could help answer your question more quickly. You can also learn more about Telegraf by enrolling at InfluxDB University for free!

Heads up, this issue will be automatically closed after 7 days of inactivity. Thank you!

@telegraf-tiger
Copy link
Contributor

Hello! I am closing this issue due to inactivity. I hope you were able to resolve your problem, if not please try posting this question in our Community Slack or Community Page. Thank you!

@gkloss
Copy link

gkloss commented Mar 6, 2023

still an Error. pls Cover the Issue.

@houm01
Copy link

houm01 commented Jan 26, 2024

still an Error. pls Cover the Issue.

Encountered the same problem, have you solved it?

@Hipska
Copy link
Contributor

Hipska commented Jun 4, 2024

@gkloss @houm01 @Dhyanesh97 Have a look at my PR #15439 which will enable you to parse this value using Starlark script. The value will now be presented as a hex string without loss of information.

@Hipska
Copy link
Contributor

Hipska commented Oct 2, 2024

Also have a look at #15935 which will enable the snmp plugin to directly format it according to the display hint format in the MIB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior support Telegraf questions, may be directed to community site or slack
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants