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

fix(metrics-operator): improve error handling in metrics providers #1466

Merged
merged 7 commits into from
May 30, 2023

Conversation

RealAnna
Copy link
Contributor

@RealAnna RealAnna commented May 25, 2023

This pr:

  1. handles hidden error in the response of metrics providers
  2. adds trim of queries from dt provider so that spaces and new lines are allowed.
  3. in case error may not be clear returns the raw value of the provider response

How to test:

  1. pass a wrong token, API returns error that is logged and stored in the KeptnMetrics ex

Status: Err Msg: provider api response: Token Authentication failed
image

  1. use a metric like so or change >- with | :
apiVersion: metrics.keptn.sh/v1alpha3
kind: KeptnMetric
metadata:
  name: podtatometric
  namespace: keptn-lifecycle-toolkit-system
spec:
  provider:
    name: "dynatrace"
  query:  >-
    (( builtin:kubernetes.workload.cpu_throttled
    :filter(eq("k8s.workload.name","frontend"))
    :splitBy("k8s.namespace.name","k8s.workload.kind","k8s.workload.name") :sum
    / builtin:kubernetes.workload.cpu_usage
    :filter(eq("k8s.deployment.name","frontend"))
    :splitBy("k8s.namespace.name","k8s.workload.kind","k8s.workload.name") :sum
    ) :default(0.0) * 100.0)
  fetchIntervalSeconds: 5

@netlify
Copy link

netlify bot commented May 25, 2023

Deploy Preview for keptn-lifecycle-toolkit ready!

Name Link
🔨 Latest commit ac8e92d
🔍 Latest deploy log https://app.netlify.com/sites/keptn-lifecycle-toolkit/deploys/646f2e0681a43b0009fda3cb
😎 Deploy Preview https://deploy-preview-1466--keptn-lifecycle-toolkit.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@codecov
Copy link

codecov bot commented May 25, 2023

Codecov Report

Merging #1466 (dcfa283) into main (30e6647) will increase coverage by 1.44%.
The diff coverage is 96.66%.

❗ Current head dcfa283 differs from pull request most recent head afce712. Consider uploading reports for the commit afce712 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1466      +/-   ##
==========================================
+ Coverage   61.62%   63.06%   +1.44%     
==========================================
  Files         137      139       +2     
  Lines       10456    10834     +378     
==========================================
+ Hits         6444     6833     +389     
+ Misses       3762     3745      -17     
- Partials      250      256       +6     
Impacted Files Coverage Δ
...r/controllers/common/providers/dynatrace/common.go 100.00% <ø> (ø)
...or/controllers/common/providers/datadog/datadog.go 78.57% <85.71%> (+1.64%) ⬆️
...ontrollers/common/providers/dynatrace/dynatrace.go 84.50% <100.00%> (+2.84%) ⬆️
...ollers/common/providers/dynatrace/dynatrace_dql.go 79.33% <100.00%> (+3.47%) ⬆️
metrics-operator/controllers/metrics/controller.go 67.64% <100.00%> (+1.49%) ⬆️

... and 15 files with indirect coverage changes

Flag Coverage Δ
certificate-operator 68.55% <ø> (ø)
component-tests 59.82% <ø> (+0.57%) ⬆️
lifecycle-operator 84.06% <ø> (+0.68%) ⬆️
metrics-operator 81.73% <96.66%> (+1.22%) ⬆️
scheduler 30.45% <ø> (+8.69%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@RealAnna RealAnna changed the title fix(metrics-operator): clean dynatrace queries fix(metrics-operator): handle hidden errors in metrics providers May 25, 2023
@RealAnna RealAnna marked this pull request as ready for review May 25, 2023 08:27
@RealAnna RealAnna requested a review from a team as a code owner May 25, 2023 08:27
@RealAnna RealAnna marked this pull request as draft May 25, 2023 08:50
@RealAnna RealAnna force-pushed the fix/query_parsing branch from 0bd2151 to ac8e92d Compare May 25, 2023 09:44
@RealAnna RealAnna marked this pull request as ready for review May 25, 2023 09:52
Signed-off-by: realanna <[email protected]>

testerrorr

Signed-off-by: realanna <[email protected]>

testerrorr

Signed-off-by: realanna <[email protected]>

testerrorr

Signed-off-by: realanna <[email protected]>

testerrorr

Signed-off-by: realanna <[email protected]>

testerrorr

Signed-off-by: realanna <[email protected]>

testerrorr

Signed-off-by: realanna <[email protected]>

testerrorr

Signed-off-by: realanna <[email protected]>

testerrorr

Signed-off-by: realanna <[email protected]>

test params

Signed-off-by: realanna <[email protected]>

test params

Signed-off-by: realanna <[email protected]>

test params

Signed-off-by: realanna <[email protected]>
@RealAnna RealAnna force-pushed the fix/query_parsing branch from ffcf9a4 to 3ab717b Compare May 25, 2023 10:08
Signed-off-by: realanna <[email protected]>
@thisthat thisthat changed the title fix(metrics-operator): handle hidden errors in metrics providers fix(metrics-operator): improve error handling in metrics providers May 25, 2023
RealAnna and others added 2 commits May 26, 2023 11:50
Co-authored-by: odubajDT <[email protected]>
Signed-off-by: RealAnna <[email protected]>
Signed-off-by: realanna <[email protected]>
@sonarcloud
Copy link

sonarcloud bot commented May 30, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@RealAnna RealAnna merged commit 9801e5d into main May 30, 2023
@RealAnna RealAnna deleted the fix/query_parsing branch May 30, 2023 09:47
@keptn-bot keptn-bot mentioned this pull request May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants