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

💡 [REQUEST] - Add Cloud Run example(s) to Cloud Monitoring backends #303

Open
1 task done
lvaylet opened this issue Nov 23, 2022 · 1 comment
Open
1 task done
Assignees
Labels
backend docs documentation Improvements or additions to documentation

Comments

@lvaylet
Copy link
Collaborator

lvaylet commented Nov 23, 2022

Summary

We have examples for App Engine, Pub/Sub and Load Balancer. Cloud Run probably deserves its own example(s) too, as it is becoming more and more popular.

Basic Example

Define your SLO in slo_cloudrun_service_availability.yaml (with MQL):

apiVersion: sre.google.com/v2
kind: ServiceLevelObjective
metadata:
  name: cloudrun-service-availability
  labels:
    service_name: cloudrun
    feature_name: service
    slo_name: availability
spec:
  description: Availability of Cloud Run service
  backend: cloud_monitoring_mql
  method: good_bad_ratio
  exporters:
  - cloud_monitoring
  service_level_indicator:
    filter_good: >
      fetch cloud_run_revision
      | metric 'run.googleapis.com/request_count'
      | filter resource.project_id == '${CLOUDRUN_PROJECT_ID}'
      | filter resource.service_name == '${CLOUDRUN_SERVICE_NAME}'
      | filter metric.response_code_class == '2xx'
    filter_valid: >
      fetch cloud_run_revision
      | metric 'run.googleapis.com/request_count'
      | filter resource.project_id == '${CLOUDRUN_PROJECT_ID}'
      | filter resource.service_name == '${CLOUDRUN_SERVICE_NAME}'
  goal: 0.85

Populate ${CLOUDRUN_PROJECT_ID} and ${CLOUDRUN_SERVICE_NAME} in .env:

export CLOUDRUN_PROJECT_ID=slo-generator-demo
export CLOUDRUN_SERVICE_NAME=cloud-run-randomly-fails

Run with:

$ source .env
$ slo-generator compute --slo-config=samples/cloud_monitoring_mql/slo_cloudrun_service_availability.yaml --config=samples/config.yaml
INFO - cloudrun-service-availability    | 1 hour   | SLI: 70.0    % | SLO: 85.0 % | Gap: -15.0 % | BR: 2.0 / 9.0 | Alert: 0 | Good: 42       | Bad: 18      
INFO - cloudrun-service-availability    | 12 hours | SLI: 76.1111 % | SLO: 85.0 % | Gap: -8.89 % | BR: 1.6 / 3.0 | Alert: 0 | Good: 548      | Bad: 172     
INFO - cloudrun-service-availability    | 7 days   | SLI: 75.4186 % | SLO: 85.0 % | Gap: -9.58 % | BR: 1.6 / 1.5 | Alert: 1 | Good: 7612     | Bad: 2481    
INFO - cloudrun-service-availability    | 28 days  | SLI: 75.0158 % | SLO: 85.0 % | Gap: -9.98 % | BR: 1.7 / 1.0 | Alert: 1 | Good: 23783    | Bad: 7921    
INFO - Run finished successfully in 7.7s.
INFO - Run summary | SLO Configs: 1 | Duration: 7.7s

Screenshots

![DESCRIPTION](LINK.png)

Drawbacks

None.

Unresolved questions

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@lvaylet lvaylet added the question Further information is requested label Nov 23, 2022
@lvaylet lvaylet self-assigned this Nov 23, 2022
@lvaylet lvaylet added documentation Improvements or additions to documentation backend docs and removed question Further information is requested labels Nov 25, 2022
@Lawouach
Copy link

Lawouach commented Feb 7, 2023

Thanks Laurent. Very much appreciated this one :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend docs documentation Improvements or additions to documentation
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants