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

slo-generator v1.0.0 #403

Merged
merged 113 commits into from
Apr 1, 2020
Merged
Changes from 1 commit
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
67b0ddb
Add support for Service Monitoring API
Jan 31, 2020
c79d027
Update package for Stackdriver Service Monitoring API support
Feb 4, 2020
b3087f3
Update documentation, fix lints
Feb 5, 2020
dabad16
Switch support for Stackdriver Service Monitoring and use Python SDK
Feb 7, 2020
336c52b
Increment version to 1.0.0
Feb 7, 2020
985a397
Improve documentation
Feb 7, 2020
b9eda14
Rename secondary error budget policy
Feb 7, 2020
17ba20d
Update linting
Feb 7, 2020
feb3613
Fix tests
Feb 7, 2020
77dc77f
Remove prometheus-client from deps
Feb 7, 2020
1edce5a
Merge v0.2 into service-monitoring-api
Feb 10, 2020
5251167
Move report generation to report.py, remove unneeded tests
Feb 10, 2020
a6e7156
Fix sample env var
Feb 10, 2020
c675744
Reformat SLO report computations in a dataclass
Feb 10, 2020
462ee53
Update SLO report dataclass
Feb 10, 2020
f26ecd2
Merge branch 'master' into slo-generator-v1.0.0
Feb 10, 2020
3dfb4c6
Update all backends to have an easier interface
Feb 10, 2020
b62888b
Fix commit merge conflicts
Feb 10, 2020
5c7c470
Fix bug
Feb 10, 2020
34a0955
Fix elasticsearch broken backend
Feb 10, 2020
9a0f75b
Run YAPF on code
Feb 10, 2020
1463a20
Update sample YAML names
Feb 12, 2020
d508677
Improve documentation for SD / SD Service Monitoring and ElasticSearch
Feb 12, 2020
db16b03
Support basic SLIs in SSM
Feb 12, 2020
e92ebd7
Support basic SLIs
Feb 12, 2020
496f07e
Update docs
Feb 12, 2020
e63e91d
Add samples/ documentation
Feb 12, 2020
031b68b
Add new samples for log-based metrics
Feb 12, 2020
483ade6
Run YAPF
Feb 12, 2020
a371124
Fix linting
Feb 13, 2020
a71efe6
Merge branch 'master' into slo-generator-v1.0.0
Feb 13, 2020
cfacbd0
Fix pylint / flake8 errors
Feb 13, 2020
e4550a6
Fix compute_slo_report
Feb 13, 2020
c01c88f
Update tests
Feb 13, 2020
255ed3c
Fix Prometheus backend
Feb 13, 2020
bd07143
Add utility to list all SLO files in folder
Feb 13, 2020
e55a267
Fix case where SLI=0
Feb 13, 2020
19afd72
Add log-based metric example
Feb 13, 2020
649d911
Update Python required version to 3.4
Feb 13, 2020
2d2f95a
Add Prometheus exporter to tests + rewrite some tests to be more legible
Feb 13, 2020
9ae342b
Add prometheus client to required dependencies
Feb 13, 2020
d242e55
remove log-based metric sample for now
Feb 13, 2020
759afce
Run YAPF on code
Feb 13, 2020
7ead29c
Fix docstring in SSM
Feb 13, 2020
e79c3db
Fix Pylint + run YAPF
Feb 13, 2020
a3a93bb
Run YAPF
Feb 13, 2020
23f6af0
Fix YAPF issue
Feb 13, 2020
04bbd35
Merge branch 'master' into slo-generator-v1.0.0
Feb 14, 2020
0278945
Fix **kwargs for SD and SD Service Monitoring
Feb 14, 2020
289c202
Improve SLO report __str__ representation
Feb 14, 2020
857164b
Improve SLO report __str__ representation
Feb 14, 2020
1447c28
Improve SLO report __str__ representation
Feb 14, 2020
475dec5
Improve SLO report __str__ representation
Feb 14, 2020
359fa65
Improve SLO report __str__ representation
Feb 14, 2020
efb56dc
Improve SLO report __str__ representation
Feb 14, 2020
8f30351
Improve SLO report __str__ representation
Feb 14, 2020
744fad9
Improve SLO report __str__ representation
Feb 14, 2020
74ac73c
Improve SLO report __str__ representation
Feb 14, 2020
635d78a
Update SSM to pick app_engine, mesh_istio sections under measurement
Feb 14, 2020
aaf0fd9
Improve detection of missing services
Feb 14, 2020
6397552
Improve detection of missing services
Feb 14, 2020
9ece060
Improve detection of missing services
Feb 14, 2020
ead9078
Improve detection of missing services
Feb 14, 2020
1db3e43
Improve detection of missing services
Feb 14, 2020
9a30c3a
Run YAPF
Feb 14, 2020
4d40db6
Add clusterIstio docs + sample for Service Monitoring API
Feb 14, 2020
9040cf3
Rename GKE_CLUSTER_LOCATION to GKE_LOCATION
Feb 14, 2020
ee28885
Improve documentation for Error Budget and Stackdriver Service Monito…
Feb 14, 2020
d2bf190
Fix docs (indenting)
Feb 14, 2020
17510de
Fix docs (indentation)
Feb 14, 2020
baf16bf
Add example for mesh_istio
Feb 14, 2020
df13dab
Format md title
Feb 14, 2020
319cf22
Format YAML in docs
Feb 14, 2020
f268776
Format YAML in docs
Feb 14, 2020
c7c5473
Remove TODO.md
Feb 14, 2020
ab2710e
Improve explanation for custom backend / exporter
Feb 14, 2020
f48cb54
Improbe README
Feb 14, 2020
7a73cdb
Limit .md line < 80 chars
Feb 14, 2020
92f12f8
Modify Elasticsearch backend to default to @timestamp for date filtering
Feb 14, 2020
a27b86e
Run YAPF
Feb 14, 2020
4b149cc
Tidy up Makefile
Feb 17, 2020
df88f3d
Fix SSM samples
Feb 17, 2020
44e7be5
Add README for using samples
Feb 17, 2020
2996a0f
Tidy up code
Feb 17, 2020
530d270
Add unit tests for Stackdriver Service Monitoring
Feb 17, 2020
df31669
Fix knit in docs
Feb 17, 2020
5ede75f
Fix samples service_name and feature_name for GKE
Feb 17, 2020
a189b34
Fix weird behaviour of SSM API with service paths
Feb 17, 2020
bca043b
Improve log output
Feb 17, 2020
0d70d71
Merge branch 'master' into slo-generator-v1.0.0
Feb 18, 2020
d5f3bea
Merge branch 'master' into slo-generator-v1.0.0
Feb 21, 2020
1caa4ff
Fix typo in README.md
Feb 24, 2020
792db70
Fix typo in README.md
Feb 24, 2020
d0c3b92
Merge branch 'master' into slo-generator-v1.0.0
Feb 27, 2020
d6860cf
Merge branch 'master' into slo-generator-v1.0.0
Mar 11, 2020
2ebafa3
Lint setup.py
Mar 12, 2020
33ee6e0
Add timestamp option to SLO generator CLI
Mar 12, 2020
a46ade1
Merge branch 'slo-generator-v1.0.0' of https://github.com/ocervell/pr…
Mar 12, 2020
0a8624d
Add timestamp arg to SLOReport class
Mar 12, 2020
7af1eff
Run YAPF
Mar 12, 2020
1bc9ee8
Add timestamp arg to SLOReport class
Mar 12, 2020
bcfd4a3
Merge branch 'master' into slo-generator-v1.0.0
Mar 13, 2020
169b7e6
Merge branch 'master' into slo-generator-v1.0.0
Mar 17, 2020
84fa150
Update tools/slo-generator/Makefile
ocervell Mar 21, 2020
026fa88
Fix knits from PR review
Mar 21, 2020
b7b64e4
Merge branch 'slo-generator-v1.0.0' of https://github.com/ocervell/pr…
Mar 21, 2020
e812422
Fix deprecation warning to 2.0
Mar 21, 2020
eb4bfa3
Loop through names instead of kwargs
Mar 21, 2020
905e3dc
Remove class name shortcut
Mar 21, 2020
6c540d1
Add return value to CLI function + add assertions in tests
Mar 21, 2020
6db9a65
Update CLI tests to check return value of cli method
Mar 21, 2020
3603f8a
Merge branch 'master' into slo-generator-v1.0.0
Mar 21, 2020
5b9006a
Merge branch 'master' into slo-generator-v1.0.0
Mar 31, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix Prometheus backend
  • Loading branch information
Olivier Cervello committed Feb 13, 2020
commit 255ed3cf6518444d1c4e0c71df3846827aae5545
11 changes: 6 additions & 5 deletions tools/slo-generator/slo_generator/backends/prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

class PrometheusBackend:
"""Backend for querying metrics from Prometheus."""

def __init__(self, client=None, url=None, headers=None):
self.client = client
if not self.client:
Expand All @@ -39,17 +38,18 @@ def __init__(self, client=None, url=None, headers=None):
LOGGER.debug(f'Prometheus headers: {headers}')
self.client = Prometheus()

def query_sli(self, slo_config):
def query_sli(self, timestamp, window, slo_config):
"""Query SLI value from a given PromQL expression.

Args:
timestamp (int): UNIX timestamp.
window (int): Window (in seconds).
slo_config (dict): SLO configuration.

Returns:
float: SLI value.
"""
conf = slo_config['backend']
window = conf['window']
measurement = conf['measurement']
expr = measurement['expression']
expression = expr.replace("[window]", f"[{window}s]")
Expand All @@ -63,10 +63,12 @@ def query_sli(self, slo_config):
LOGGER.debug(f"SLI value: {sli_value}")
return sli_value

def good_bad_ratio(self, slo_config):
def good_bad_ratio(self, timestamp, window, slo_config):
"""Compute good bad ratio from two metric filters.

Args:
timestamp (int): UNIX timestamp.
window (int): Window (in seconds).
slo_config (dict): SLO configuration.

Note:
Expand All @@ -76,7 +78,6 @@ def good_bad_ratio(self, slo_config):
tuple: A tuple of (good_event_count, bad_event_count).
"""
conf = slo_config['backend']
window = slo_config['window']
filter_good = conf['measurement']['filter_good']
filter_bad = conf['measurement'].get('filter_bad')
filter_valid = conf['measurement'].get('filter_valid')
Expand Down