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.opensearch_query): Add opensearch_query input plugin #12393

Merged
merged 45 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
7b0885b
Initial commit: add support for input/opensearch_query
Dec 12, 2022
f45fb68
Add TLS support
Dec 13, 2022
07ee619
Fix bug getting field mappings on a wildcard index
Dec 13, 2022
cf8c210
Finish renaming from Elasticsearch to Opensearch
Dec 13, 2022
3a1495f
Update README.md; update sample config
Dec 13, 2022
e684460
go mod tidy
Dec 13, 2022
a96e9d3
Update docs/LICENSE_OF_DEPENDENCIES.md
Dec 13, 2022
e1bb29e
Update README.md to conform
Dec 13, 2022
958e8f7
Lint
Dec 13, 2022
1caabf5
Lint
Dec 13, 2022
4195041
Lint
Dec 13, 2022
214304b
Fix error handling; refactor tests to better check for errors; lint
NullOranje Dec 15, 2022
ab9651c
Update LICENSE_OF_DEPENDENCIES.md per circleci make check-deps job
NullOranje Dec 15, 2022
fabc895
Use HTTPS for testing (demo certs; InsecureSkipVerify)
NullOranje Dec 15, 2022
c0d73d6
Fix error handling; remove duplicated client initialization
NullOranje Dec 20, 2022
c8d0650
Add request structs for use with opensearchapi
NullOranje Dec 19, 2022
205102b
(Broken) Refactor aggregation request to eliminate olivere library
NullOranje Dec 23, 2022
3456787
Refactor to remove olivere/elastic library; rewrite metric collection…
NullOranje Dec 28, 2022
3fc08f5
Update buildAggregationQuery test
NullOranje Dec 28, 2022
9991916
Remove unused code
NullOranje Dec 28, 2022
903bbf6
Add support for nested values, such as from percentiles; update tests…
NullOranje Dec 28, 2022
6f5bee9
Add support for extended_stats; update tests; update README.md
NullOranje Dec 28, 2022
7d2b0b5
Log initial failure to cluster instead of failing
NullOranje Dec 28, 2022
f1ca696
Lint README.md
NullOranje Dec 28, 2022
088b55b
Refactor/reorganize/lint code
NullOranje Dec 28, 2022
d8fca36
Lint test
NullOranje Dec 28, 2022
bd902f3
go mod tidy
NullOranje Dec 29, 2022
7c34c0b
Update sample.conf; update README.md
Dec 29, 2022
af49ef8
Lint README.md
NullOranje Dec 29, 2022
ded4ce8
Code cleanup
NullOranje Jan 5, 2023
0eadc9d
Merge branch 'influxdata:master' into master
NullOranje Jan 5, 2023
861a7b4
Code cleanup per review comments
NullOranje Jan 9, 2023
dc6b0f7
Update code per review comments
NullOranje Jan 23, 2023
be67c4c
Merge branch 'influxdata:master' into master
NullOranje Jan 23, 2023
b0da877
make docs
NullOranje Jan 23, 2023
0560bc5
Add support for secret stores
Jan 24, 2023
eb349d8
Move test data out of globals
Jan 26, 2023
ab1a4ba
Cleanup test opensearch client
Jan 26, 2023
909a1bf
Merge remote-tracking branch 'upstream/master'
Jan 26, 2023
cc3261a
Update from master
Jan 26, 2023
8d08405
Fix test case
NullOranje Jan 31, 2023
372c425
Add OpenSearch 1.3.7 to test cases; bump Opensearch 2.x to 2.5.0 ; te…
NullOranje Jan 31, 2023
33d42f4
Update plugins/inputs/opensearch_query/opensearch_query.go
powersj Feb 1, 2023
120d2e2
Removed unused function and associated test; updated README.md; error…
NullOranje Feb 2, 2023
5ddf598
Lint
NullOranje Feb 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,6 @@ github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.2.3/go.mod h1:7gc
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.3.2/go.mod h1:72HRZDLMtmVQiLG2tLfQcaWLCssELvGl+Zf2WVxMmR8=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.5.0/go.mod h1:Mq6AEc+oEjCUlBuLiK5YwW4shSOAKCQ3tXN0sQeYoBA=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.7/go.mod h1:HvVdEh/x4jsPBsjNvDy+MH3CDCPy4gTZEzFe2r4uJY8=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.15/go.mod h1:ZVJ7ejRl4+tkWMuCwjXoy0jd8fF5u3RCyWjSVjUIvQE=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.17/go.mod h1:4nYOrY41Lrbk2170/BGkcJKBhws9Pfn8MG3aGqjjeFI=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.19/go.mod h1:02CP6iuYP+IVnBX5HULVdSAku/85eHB2Y9EsFhrkEwU=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.21 h1:5C6XgTViSb0bunmU57b3CT+MhxULqHH2721FVA+/kDM=
Expand Down
21 changes: 16 additions & 5 deletions plugins/inputs/opensearch_query/opensearch_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ var sampleConfig string
// OpensearchQuery struct
type OpensearchQuery struct {
URLs []string `toml:"urls"`
Username string `toml:"username"`
Password string `toml:"password"`
Username config.Secret `toml:"username"`
Password config.Secret `toml:"password"`
EnableSniffer bool `toml:"enable_sniffer"`
Timeout config.Duration `toml:"timeout"`
HealthCheckInterval config.Duration `toml:"health_check_interval"`
Expand Down Expand Up @@ -119,10 +119,21 @@ func (o *OpensearchQuery) initAggregation(agg osAggregation, i int) (err error)
}

func (o *OpensearchQuery) newClient() error {
username, err := o.Username.Get()
if err != nil {
return fmt.Errorf("getting username failed: %v", err)
NullOranje marked this conversation as resolved.
Show resolved Hide resolved
}
defer config.ReleaseSecret(username)
password, err := o.Password.Get()
if err != nil {
return fmt.Errorf("getting password failed: %v", err)
NullOranje marked this conversation as resolved.
Show resolved Hide resolved
}
defer config.ReleaseSecret(password)

clientConfig := opensearch.Config{
Addresses: o.URLs,
Username: o.Username,
Password: o.Password,
Username: string(username),
Password: string(password),
}

if o.InsecureSkipVerify {
Expand Down Expand Up @@ -202,7 +213,7 @@ func (o *OpensearchQuery) runAggregationQuery(ctx context.Context, aggregation o
aq.Query = boolQuery
req, err := json.Marshal(aq)
if err != nil {
return nil, fmt.Errorf("failed to marshal request: %s", err)
return nil, fmt.Errorf("failed to marshal request: %w", err)
}

searchRequest := &opensearchapi.SearchRequest{
Expand Down
Loading