-
Notifications
You must be signed in to change notification settings - Fork 641
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
Parse date and time from DisplayString #1232
Comments
I think this would be a great idea. The resulting output should follow the Prometheus convention of returning a UNIX epoch timestamp in seconds as the value. Personally I would prefer strftime parser over Go's weirdo format. I think this has been proposed in the past. But of course I can't find the feature request in the issue tracker right now. |
Yes I totally agree.
I have suggested the time module to avoid additional dependencies and all the stftime modules only have a few stars on github. But if we all agree on using the suggested stftime module I can provide a PR and use it instead the time. |
We can do some more research on time parse libraries. That is a small component to swap out. |
Add new type ParseDateAndTime to parse timestamps from DisplayString and report it as unix timestamp.
Add new type ParseDateAndTime to parse timestamps from DisplayString and report it as unix timestamp. Signed-off-by: PhiBo <[email protected]>
Add new type ParseDateAndTime to parse timestamps from DisplayString and report it as unix timestamp. Signed-off-by: PhiBo <[email protected]>
Host operating system: output of
uname -a
Docker on Linux
snmp_exporter version: output of
snmp_exporter -version
What device/snmpwalk OID are you using?
If this is a new device, please link to the MIB(s).
https://docs.sophos.com/nsg/sophos-firewall/MIB/SOPHOS-XG-MIB.zip
What did you do that produced an error?
What did you expect to see?
Parse the date and time and report the timestamp
What did you see instead?
I'm currently working on including Sophos XG devices. But at the moment I haven't finished a PR because the snmp_exporter is unable to parse date and time from a DisplayString.
If a valid license has been provided the output looks like the example below.
If a license is not available the output will look like.
Also there is a value for the current time.
New feature
Would be great if the exporter can parse the date and time and report the timestamp similar to the
DateAndTime
type.To solve the issue I would like to add a new type
ParseDateAndTime
and use thetime.Parse()
https://pkg.go.dev/time#Parse function to parse the value. If go is unable to parse the date I would skip the metric.Example config:
What do you think about it? Is it worth to implement this feature and open a PR or is it out of scope for the snmp_exporter?
The text was updated successfully, but these errors were encountered: