-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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(outputs.opensearch): opensearch output plugin #11958
Conversation
#11345 All test cases passed with Opensearch 1.1.0 and 2.2.1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I know in the referenced FR it was decided to create a separate plugin, I'm wondering what is different to ES in this case, as it looks like the exact same API module is being used.
Thought of using the opensearch-go client, but as of now there is no stable version which can support both 1.x and 2.x. Maybe we can update the client in future. |
We recently added the opensearch_query input plugin that uses that library, tested with both versions. In that PR we had a discussion about not using the |
I was in opinion that opensearch-go/v2 is not backward compatible, but if it works with both will try to use this if you can confirm we need this change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still in favour of using golang templates instead of something mixed and a lookalike of it.
We do not want any further plugins dependent on @NullOranje - when you looked at testing the new opensearch_query plugin you contributed, did you have to do anything special to test OpenSearch 1 and 2? Were there any compatibility issues? |
@powerjs No, I didn't do anything differently other than test against a v1 container. I'm not sure what the breaking API changes might be in |
@mannukalra, what do you think about using |
That makes sense to me. |
Sure @powersj, that also sounds good, will try to make the change in the coming weeks. |
Can you mark the PR as draft in the meantime please? |
Any progress on the updates to this PR? I know it is in draft, but trying to get an idea of the status of current PRs. Thanks! |
@powersj, sorry it's been delayed a bit, will update shortly on the progress. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Finally using the full power of GoLang templates!
Some minor remarks..
// Determine if we should process NaN and inf values | ||
valOptions := []string{"", "none", "drop", "replace"} | ||
if err := choice.Check(o.FloatHandling, valOptions); err != nil { | ||
return fmt.Errorf("config float_handling type %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Errorf("config float_handling type %w", err) | |
return fmt.Errorf("config float_handling type: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
indexTmpl, err := template.New("index").Parse(o.IndexName) | ||
if err != nil { | ||
return fmt.Errorf("error parsing indextemplate %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Errorf("error parsing indextemplate %w", err) | |
return fmt.Errorf("error parsing index_name template: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
|
||
pipelineTmpl, err := template.New("index").Parse(o.UsePipeline) | ||
if err != nil { | ||
return fmt.Errorf("error parsing pipelineTemplate for UsePipeline %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Errorf("error parsing pipelineTemplate for UsePipeline %w", err) | |
return fmt.Errorf("error parsing use_pipeline template: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
plugins/outputs/opensearch/README.md
Outdated
|
||
For example: "telegraf-{{.Time.Format "2006-01-02"}}" would set it to telegraf-2023-07-27 | ||
You can also specify | ||
metric name (`{{Name}}`), tag value (`{{Tag "tag_name"}}`), field value (`{{Field "feild_name"}}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
metric name (`{{Name}}`), tag value (`{{Tag "tag_name"}}`), field value (`{{Field "feild_name"}}`) | |
metric name (`{{ .Name }}`), tag value (`{{ .Tag "tag_name" }}`), field value (`{{ .Field "feild_name" }}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
## %Y - year (2016) | ||
## %y - last two digits of year (00..99) | ||
## %m - month (01..12) | ||
## %d - day of month (e.g., 01) | ||
## %H - hour (00..23) | ||
## %V - week of the year (ISO week) (01..53) | ||
## For example: telegraf-%Y.%m.%d would set it to telegraf-2006-01-02 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still the old way, please update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
## Additionally, you can specify a tag name using the notation {{tag_name}} | ||
## which will be used as part of the index name: "telegraf-{{host}}-%Y.%m.%d" | ||
## If the tag does not exist, the default tag value will be used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would mention the possibility to use tags in the relevant section of "Index Name" and here just what happens if that tag doesn't exist..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be replaced with empty sting, have explained.
Just so you know- don't see a scope of handling the default_tag_value anymore with this implementation(have tried in test-cases, it only replaced with "" and not the value specified for DefaultTagValue), so removed DefaultTagValue field from struct. Let me know if I'm mistaken here and it can still work.
## Additionally, you can specify a tag name using the notation {{tag_name}} | ||
## which will be used as part of the pipeline name (e.g. "{{es_pipeline}}"). | ||
## If the tag does not exist, the default pipeline will be used as the | ||
## pipeline. If no default pipeline is set, no pipeline is used for the | ||
## metric. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, explain the usage of tags directly in "Pipeline Config".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the work!
@mannukalra would you please be so kind to fix the CI tests before I'm doing the review!? It should be a I'm usually running |
I've cleaned up the PR so tests at least pass locally, will check CI shortly. I do want to do a review before we land as well. |
@powersj Still needs a |
Download PR build artifacts for linux_amd64.tar.gz, darwin_amd64.tar.gz, and windows_amd64.zip. 🥳 This pull request decreases the Telegraf binary size by -2.32 % for linux amd64 (new size: 197.3 MB, nightly size 202.0 MB) 📦 Click here to get additional PR build artifactsArtifact URLs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all your effort @mannukalra and thanks for fixing the remaining issues @powersj!
Thank you all for your support 😊 |
Required for all PRs
resolves #11345