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

Add error count metrics #110

Merged
merged 8 commits into from
May 6, 2023

Conversation

excalq
Copy link
Contributor

@excalq excalq commented Apr 28, 2023

Resolves #109. Adds metrics, test expected metrics, fixtures, structs, and snapshots.

Adds new metrics as follows:

# HELP logstash_stats_pipeline_plugin_bulk_requests_errors Number of bulk request errors.
# TYPE logstash_stats_pipeline_plugin_bulk_requests_errors counter
logstash_stats_pipeline_plugin_bulk_requests_errors{pipeline="telemetry-json",plugin="opensearch",plugin_id="6c1a6024",plugin_type="output"} 2
logstash_stats_pipeline_plugin_bulk_requests_errors{pipeline="telemetry-json",plugin="stdout",plugin_id="acba4948",plugin_type="output"} 0
logstash_stats_pipeline_plugin_bulk_requests_errors{pipeline="telemetry-legacy",plugin="opensearch",plugin_id="059ed188",plugin_type="output"} 0
logstash_stats_pipeline_plugin_bulk_requests_errors{pipeline="testing-stdout",plugin="stdout",plugin_id="fd7f574d",plugin_type="output"} 0

# HELP logstash_stats_pipeline_plugin_bulk_requests_responses Bulk request HTTP response counts by code.
# TYPE logstash_stats_pipeline_plugin_bulk_requests_responses counter
logstash_stats_pipeline_plugin_bulk_requests_responses{code="200",pipeline="telemetry-json",plugin="opensearch",plugin_id="6c1a6024",plugin_type="output"} 2
logstash_stats_pipeline_plugin_bulk_requests_responses{code="200",pipeline="telemetry-legacy",plugin="opensearch",plugin_id="059ed188",plugin_type="output"} 2

# HELP logstash_stats_pipeline_plugin_documents_non_retryable_failures Number of output events with non-retryable failures.
# TYPE logstash_stats_pipeline_plugin_documents_non_retryable_failures counter
logstash_stats_pipeline_plugin_documents_non_retryable_failures{pipeline="telemetry-json",plugin="opensearch",plugin_id="6c1a6024",plugin_type="output"} 2
logstash_stats_pipeline_plugin_documents_non_retryable_failures{pipeline="telemetry-json",plugin="stdout",plugin_id="acba4948",plugin_type="output"} 0
logstash_stats_pipeline_plugin_documents_non_retryable_failures{pipeline="telemetry-legacy",plugin="opensearch",plugin_id="059ed188",plugin_type="output"} 0
logstash_stats_pipeline_plugin_documents_non_retryable_failures{pipeline="testing-stdout",plugin="stdout",plugin_id="fd7f574d",plugin_type="output"} 0

# HELP logstash_stats_pipeline_plugin_documents_successes Number of successful bulk requests.
# TYPE logstash_stats_pipeline_plugin_documents_successes counter
logstash_stats_pipeline_plugin_documents_successes{pipeline="telemetry-json",plugin="opensearch",plugin_id="6c1a6024",plugin_type="output"} 0
logstash_stats_pipeline_plugin_documents_successes{pipeline="telemetry-json",plugin="stdout",plugin_id="acba4948",plugin_type="output"} 0
logstash_stats_pipeline_plugin_documents_successes{pipeline="telemetry-legacy",plugin="opensearch",plugin_id="059ed188",plugin_type="output"} 2
logstash_stats_pipeline_plugin_documents_successes{pipeline="testing-stdout",plugin="stdout",plugin_id="fd7f574d",plugin_type="output"} 0

Note, as I'm pre-populating all counters with 0 (except for bulk HTTP response codes), there is some additional nil checking and looping. Does this merit additional tests?

@codecov
Copy link

codecov bot commented Apr 28, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (607efa9) 100.00% compared to head (4e6143f) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #110   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           12        12           
  Lines          496       513   +17     
=========================================
+ Hits           496       513   +17     
Impacted Files Coverage Δ
collectors/nodestats/pipeline_subcollector.go 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@kuskoman
Copy link
Owner

@excalq lint seems to fail:

Run golangci-lint run
Error: collectors/nodestats/pipeline_subcollector.go:117:6: SA4022: the address of a variable cannot be nil (staticcheck)
		if &output.Documents != nil {
		   ^
Error: collectors/nodestats/pipeline_subcollector.go:122:6: SA4022: the address of a variable cannot be nil (staticcheck)
		if &output.BulkRequests != nil {
		   ^
Error: Process completed with exit code 1.

@excalq
Copy link
Contributor Author

excalq commented May 1, 2023

I learned something new in Golang: https://www.sohamkamani.com/golang/omitempty/
I'm going to remove the omitempty and the conditional checks, then we should ok.

@excalq excalq requested a review from kuskoman May 2, 2023 19:26
@excalq
Copy link
Contributor Author

excalq commented May 2, 2023

@kuskoman I've updated the structs snapshot to fix Github's checks. This should be ready for review.

@kuskoman kuskoman changed the title Excalq/add error count metrics Add error count metrics May 5, 2023
@kuskoman
Copy link
Owner

kuskoman commented May 5, 2023

@excalq after merging master to the branch integration test seems to fail, could you re-generate the metrics?

@excalq
Copy link
Contributor Author

excalq commented May 5, 2023

@excalq after merging master to the branch integration test seems to fail, could you re-generate the metrics?

@kuskoman I'm having trouble reproducing this. make verify-metrics returns 0, and tests pass. What am I missing?

@kuskoman kuskoman merged commit 3f03c69 into kuskoman:master May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Output failures are not logged
2 participants