Skip to content

Commit

Permalink
fix: update api endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandoataoldotcom authored Apr 24, 2023
1 parent 5be4cc6 commit 94d3221
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
logger.addHandler(handler)

# configure loki endpoint values
LOKI_BACKEND_ENDPOINT = os.environ['LOKI_BACKEND_ENDPOINT']
LOKI_API_ENDPOINT = os.environ['LOKI_API_ENDPOINT']
LOKI_POST_HEADERS = {"Content-Type": "application/yaml"}

def create_or_update_alerting_rule_group(
rule_namespace,
yaml_rule_group_definition,
):
response = requests.post(
f'{LOKI_BACKEND_ENDPOINT}/loki/api/v1/rules/{rule_namespace}',
f'{LOKI_API_ENDPOINT}/loki/api/v1/rules/{rule_namespace}',
data=yaml_rule_group_definition,
headers=LOKI_POST_HEADERS
)
Expand All @@ -39,20 +39,20 @@ def delete_alerting_rule_group(
rule_name,
):
response = requests.delete(
f'{LOKI_BACKEND_ENDPOINT}/loki/api/v1/rules/{rule_namespace}/{rule_name}'
f'{LOKI_API_ENDPOINT}/loki/api/v1/rules/{rule_namespace}/{rule_name}'
)
return response

def get_alerting_rules():
response = requests.get(
f'{LOKI_BACKEND_ENDPOINT}/loki/api/v1/rules'
f'{LOKI_API_ENDPOINT}/loki/api/v1/rules'
)
return yaml.safe_load(response.text)

# Not used, since getting state from the API isn't needed for finalizers
def get_alerting_rules_in_namespace(rule_namespace,):
response = requests.get(
f'{LOKI_BACKEND_ENDPOINT}/loki/api/v1/rules/{rule_namespace}'
f'{LOKI_API_ENDPOINT}/loki/api/v1/rules/{rule_namespace}'
)
return yaml.safe_load(response.text)[rule_namespace][0]

Expand Down

0 comments on commit 94d3221

Please sign in to comment.