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

feat(inputs.jti_openconfig_telemetry): set timestamp from data #12730

Merged
merged 5 commits into from
Feb 27, 2023

Conversation

powersj
Copy link
Contributor

@powersj powersj commented Feb 23, 2023

Allows a user to use the _timestamp from the data rather than the collection time.

fixes: #12695

Allows a user to use the _timestamp from the data rather than the
collection time.

fixes: influxdata#12695
@telegraf-tiger telegraf-tiger bot added feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Feb 23, 2023
@powersj powersj self-assigned this Feb 23, 2023
@powersj powersj marked this pull request as ready for review February 24, 2023 14:32
@powersj powersj added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Feb 24, 2023
@powersj powersj assigned srebhan and unassigned powersj Feb 24, 2023
Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @powersj! I have one suggestion regarding the option value and one concern regarding the type-assertion...

Comment on lines 37 to 39
## Set to 'current' for time of collection, and 'data' for using the time
## provided by the _timestamp field.
# timestamp_source = "current"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe

Suggested change
## Set to 'current' for time of collection, and 'data' for using the time
## provided by the _timestamp field.
# timestamp_source = "current"
## Set to 'collection' for time of collection, and 'data' for using the time
## provided by the _timestamp field.
# timestamp_source = "collection"

would be more clear?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it - done

// Iterate through data groups and add them
for _, group := range dgroups {
if m.TimestampSource == "data" {
// OpenConfig timestamp is in milliseconds since epoch
timestamp = time.UnixMilli(int64(group.data["_timestamp"].(uint64)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would really like to check the assertion here to prevent a panic

Suggested change
timestamp = time.UnixMilli(int64(group.data["_timestamp"].(uint64)))
ts, ok := group.data["_timestamp"].(uint64)
if ok {
timestamp = time.UnixMilli(int64(ts))
} else {
m.Log.Warnf("invalid type %T for _timestamp %v", group.data["_timestamp"], group.data["_timestamp"])
}

As background, my experience for GNMI tells me that behavior among vendors (or even between models) is not necessarily conforming to any expectations and might vary. So better be safe than sorry... Maybe the warning could be a "warn only once" thing...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed on type conversion - done.

Given this is opt-in, let's log each time and see if we get any issues that come through.

@telegraf-tiger
Copy link
Contributor

Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update @powersj!

@srebhan srebhan merged commit d40f46e into influxdata:master Feb 27, 2023
@srebhan srebhan added this to the v1.26.0 milestone Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use '_timestamp' field out of the collected JTI metrics
2 participants