Skip to main content

Setting SLOs on HTTP Paths and RPC Methods

You can set SLOs on HTTP Paths or RPC Methods that represent key endpoints for your application (for example, revenue-critical URIs or core RPC methods).

Enabling SLOs on these entities configures SLO tracking for both Request Duration and Request Error Rate. When a root cause impacts one of these endpoints and drives its SLO at risk or into violation, Causely treats that root cause as Urgent.

The recommended way to manage these SLOs is to use Entity Configs of type EntityTier.

Prerequisite

Each example below reuses the helper utilities defined in the Authentication and GraphQL Clients sections (get_causely_access_token, create_graphql_client, post_query, and their language equivalents).

Enable SLOs on an HTTP Path or RPC Method

import os
import json

# Reuse helpers defined earlier in this guide:
# - get_causely_access_token
# - create_graphql_client
# - post_query

CREATE_CONFIGS_MUTATION = """
mutation CreateEntityConfigs($entityConfigs: [EntityConfigInput!]!) {
createEntityConfigs(entityConfigs: $entityConfigs) {
entityId
type
data
}
}
"""

if __name__ == "__main__":
cid, secret = os.getenv("CAUSELY_CLIENT_ID"), os.getenv("CAUSELY_CLIENT_SECRET")
if not cid or not secret:
raise EnvironmentError("Missing CAUSELY_CLIENT_ID or CAUSELY_CLIENT_SECRET")

token = get_causely_access_token(cid, secret)
client = create_graphql_client(token)

# Replace with the entityId of the HTTP Path or RPC Method you want to enable SLOs on
entity_id = "7c4bba4c-1942-5fc4-87e2-d1f2c483d2c2"

variables = {
"entityConfigs": [{
"type": "EntityTier",
"entityId": entity_id,
"data": "sloEnabled",
}]
}

result = post_query(client, CREATE_CONFIGS_MUTATION, variables)
print(json.dumps(result, indent=2))

Check whether an HTTP Path or RPC Method has SLOs enabled

import os
import json

# Reuse helpers defined earlier:
# - get_causely_access_token
# - create_graphql_client
# - post_query

GET_CONFIGS_QUERY = """
query GetEntityConfigs($entityId: String!) {
entityConfigs(entityId: $entityId) {
type
data
entityId
}
}
"""

if __name__ == "__main__":
cid, secret = os.getenv("CAUSELY_CLIENT_ID"), os.getenv("CAUSELY_CLIENT_SECRET")
if not cid or not secret:
raise EnvironmentError("Missing CAUSELY_CLIENT_ID or CAUSELY_CLIENT_SECRET")

token = get_causely_access_token(cid, secret)
client = create_graphql_client(token)

entity_id = "2f3ce84a-18b8-5d4c-820d-5b747cbb7f13"

result = post_query(client, GET_CONFIGS_QUERY, {"entityId": entity_id})
print(json.dumps(result, indent=2))

Remove SLOs from an HTTP Path or RPC Method

import os
import json

# Reuse helpers defined earlier:
# - get_causely_access_token
# - create_graphql_client
# - post_query

DELETE_CONFIG_MUTATION = """
mutation DeleteEntityConfig($entityId: String!, $configType: String!) {
deleteEntityConfig(entityId: $entityId, configType: $configType)
}
"""

if __name__ == "__main__":
cid, secret = os.getenv("CAUSELY_CLIENT_ID"), os.getenv("CAUSELY_CLIENT_SECRET")
if not cid or not secret:
raise EnvironmentError("Missing CAUSELY_CLIENT_ID or CAUSELY_CLIENT_SECRET")

token = get_causely_access_token(cid, secret)
client = create_graphql_client(token)

entity_id = "2f3ce84a-18b8-5d4c-820d-5b747cbb7f13"

result = post_query(client, DELETE_CONFIG_MUTATION, {
"entityId": entity_id,
"configType": "EntityTier"
})

print(json.dumps(result, indent=2))