pyrra icon indicating copy to clipboard operation
pyrra copied to clipboard

SLO does not pick up errors

Open akosyakov opened this issue 1 year ago • 10 comments

We have a weird issue that SLO does not reflect errors properly. Availability says 0 errors, while we can see that there are valid errors. So SLO is always 100%. Screenshot 2023-07-03 at 10 04 43 Screenshot 2023-07-03 at 10 04 52

How could we troubleshoot such issues?

akosyakov avatar Jul 03 '23 08:07 akosyakov

Hi Anton, long time no see 😄

Would it be okay to share the SLO spec?


The errors displayed there are fetched from a recording rule generated by Pyrra called "increase:error metric name:slo window"

To start troubleshooting I would look for log errors in both Pyrra and Prometheus that might correlate with this metric

ArthurSens avatar Jul 03 '23 10:07 ArthurSens

Yeah, as @ArthurSens said, it seems like the recording rules aren't properly running in the background in Prometheus.

metalmatze avatar Jul 03 '23 15:07 metalmatze

Hey @ArthurSens , @metalmatze here's our SLO rules

apiVersion: pyrra.dev/v1alpha1
kind: ServiceLevelObjective
...
spec:
  alerting:
    name: VSCodeDesktopLocalSSHConnection
  description: 99% of connection connection over local ssh proxy is succeed
  indicator:
    ratio:
      errors:
        metric: vscode_desktop_local_ssh_total{phase="failed", failure_code!~"NoRunningInstance|FailedToGetAuthInfo:UNAVAILABLE|FailedToGetAuthInfo:CANCELLED"}
      grouping: null
      total:
        metric: vscode_desktop_local_ssh_total{phase!="connecting"}
  target: "99.0"
  window: 4w

Long time no see @ArthurSens 🙌 😄

mustard-mh avatar Jul 04 '23 07:07 mustard-mh

It seems the label phase is not included by pyrra, ~~then reset related data in pyrra should work~~

image

mustard-mh avatar Jul 04 '23 07:07 mustard-mh

Hey @metalmatze , we resolve this problem temporarily by make total metric query with vscode_desktop_local_ssh_total{phase!~"connecting"} ☝️ https://github.com/pyrra-dev/pyrra/issues/794#issuecomment-1619629927

And we found in code base, for ratio type, if we have error (phase~=xxx, failure_code) and total (phase!=xx), it will

  • list labels from error -> current phase, failure_code
  • delete labels from total [1] -> current failure_code
  • add labels back if they are regexp [2] -> current failure_code

So result labels will contain failure_code only, it looks like a bug of pyrra?

Maybe check if label value is equal before delete is required?

mustard-mh avatar Jul 04 '23 09:07 mustard-mh

The way I read your configuration and how the total metric is supposed to work you shouldn't filter for the connecting at all. The total metric should include all counters.

      total:
-        metric: vscode_desktop_local_ssh_total{phase!="connecting"}
+        metric: vscode_desktop_local_ssh_total

The resulting recording rule won't include the phase labels as those are part of both the total and error metric.

metalmatze avatar Jul 04 '23 13:07 metalmatze

It's about how we report metrics, we have phase connecting connected failed, so we need a label matcher vscode_desktop_local_ssh_total{phase!="connecting"}

mustard-mh avatar Jul 06 '23 13:07 mustard-mh

The way I read your configuration and how the total metric is supposed to work you shouldn't filter for the connecting at all. The total metric should include all counters.

While I agree that this is probably the best way to implement an SLO, would it make sense to not be so restrict about it?

I can see the case where metrics exposed by external services just don't follow this pattern, so building an SLO with them becomes extra difficult.

It's about how we report metrics, we have phase connecting connected failed, so we need a label matcher vscode_desktop_local_ssh_total{phase!="connecting"}

@mustard-mh, as a workaround, do you need the metric with phase=connecting label for any other reason that is not the SLO? Would it be fine to add a relabeling rule to your prometheus to drop the metric? Or even better, if you have access to the codebase that exposes this metric, could you update the instrumentation to not increment the counter during this phase?

ArthurSens avatar Jul 06 '23 13:07 ArthurSens

While I agree that this is probably the best way to implement an SLO, would it make sense to not be so restrict about it?

Yes, fair enough, and also for those circumstances where you aren't in control of the metrics. I guess a relabeling rule might work indeed.

I think this issue is mostly about how we tried labels and how they cancel out in the generic rules (for Grafana etc), right? In that case, we might be able to come up with a test case and implement a fix.

Sadly, I've prioritized some other work for Pyrra right now and might not get to this soon. If anyone wants to try I'm happy to help!

metalmatze avatar Jul 06 '23 15:07 metalmatze

@mustard-mh, as a workaround, do you need the metric with phase=connecting label for any other reason that is not the SLO?

It's a part of user flow telemetry before: connecting -> connected, connecting -> failed, connecting->abort, but yes if it's metric then we can have only connected and failed.

Right now as a workaround, use {phase!~"connecting"} or {phase~="connected|failed"} can make it work

mustard-mh avatar Jul 06 '23 19:07 mustard-mh