-
Notifications
You must be signed in to change notification settings - Fork 8k
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
[Infrastructure UI][Rules] Add logging to Metric Threshold Rule #132343
[Infrastructure UI][Rules] Add logging to Metric Threshold Rule #132343
Conversation
e846af4
to
5461779
Compare
5461779
to
5b274a3
Compare
5b274a3
to
d537560
Compare
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
Pinging @elastic/infra-monitoring-ui (Team:Infra Monitoring UI) |
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.
Got some logs LGTM
[2022-05-18T10:32:46.473+09:00][TRACE][plugins.infra.metricThresholdRule] [AlertId: 69402c20-d64a-11ec-840b-fdd156179a03][ExecutionId: 8005ed8e-8c4f-46df-a4e6-cf9e8c65e14e] Request: {"index":"metrics-*,metricbeat-*","allow_no_indices":true,"ignore_unavailable":true,"body":{"track_total_hits":true,"query":{"bool":{"filter":[{"range":{"@timestamp":{"gte":"2022-05-18T01:31:46.339Z","lte":"2022-05-18T01:32:46.339Z"}}},{"exists":{"field":"system.cpu.total.pct"}}]}},"size":0,"aggs":{"all":{"filters":{"filters":{"all":{"match_all":{}}}},"aggs":{"currentPeriod":{"filter":{"range":{"@timestamp":{"gte":"2022-05-18T01:31:46.339Z","lte":"2022-05-18T01:32:46.339Z"}}},"aggs":{"aggregatedValue":{"avg":{"field":"system.cpu.total.pct"}}}},"shouldWarn":{"bucket_script":{"buckets_path":{},"script":"0"}},"shouldTrigger":{"bucket_script":{"buckets_path":{"value":"currentPeriod>aggregatedValue"},"script":"params.value > 0.3 ? 1 : 0"}}}}}}}
[2022-05-18T10:32:46.485+09:00][TRACE][plugins.infra.metricThresholdRule] [AlertId: 69402c20-d64a-11ec-840b-fdd156179a03][ExecutionId: 8005ed8e-8c4f-46df-a4e6-cf9e8c65e14e] Response: {"took":8,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":{"value":6,"relation":"eq"},"max_score":null,"hits":[]},"aggregations":{"all":{"buckets":{"all":{"doc_count":6,"currentPeriod":{"doc_count":6,"aggregatedValue":{"value":0.11966666666666666}},"shouldWarn":{"value":0},"shouldTrigger":{"value":0}}}}}}
error: fakeLogger, | ||
fatal: fakeLogger, | ||
log: sinon.stub(), | ||
get: sinon.stub(), |
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've been trying to avoid sinon in favor of jest.fn
in my tests but looks like this isn't really net-new code so LGTM.
@@ -240,6 +246,8 @@ export const createMetricThresholdExecutor = (libs: InfraBackendLibs) => | |||
}); | |||
} | |||
} | |||
const stopTime = Date.now(); | |||
logger.debug(`Scheduled ${scheduledActionsCount} actions in ${stopTime - startTime}ms`); |
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 makes me think about APM tracing :) Guess logging is probably a more critical base feature though.
Summary
This PR adds logging for the execution time (debug) along with the Elasticsearch request/responses (trace) to the Metric Threshold Rule.
To enable the logging for the Metric Threshold rule, add the following snippet to your
config/kibana.dev.yml
:Example Log Format
Checklist