Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(logs): rename SNUFFLE_* settings to SNUFFLE_APM_* (#100360)

Frank Hamandf5bf81c3d47f
diff --git a/docs/published/docs/logs/logql-api.mdx b/docs/published/docs/logs/logql-api.mdx
index c7484577566a..81c94aaf1a48 100644
--- a/docs/published/docs/logs/logql-api.mdx
+++ b/docs/published/docs/logs/logql-api.mdx
@@ -66,8 +66,8 @@ The endpoint shares the [API rate limits](/docs/api#rate-limiting) of the projec
The endpoint proxies to [Snuffle](https://github.com/PostHog/snuffle), which runs next to the logs ClickHouse cluster. Configure it with these environment variables on the web pods:
-| Variable | Purpose |
-| ----------------------------------- | ---------------------------------------------------------------------------------------------------- |
-| `SNUFFLE_URL` | Base URL of Snuffle. Empty turns the endpoint off and it answers `501`. |
-| `SNUFFLE_USER` / `SNUFFLE_PASSWORD` | ClickHouse credential that Snuffle uses. Defaults to the logs cluster user. Prefer a read-only user. |
-| `SNUFFLE_TIMEOUT_SECONDS` | Upstream request timeout. Default `60`. |
+| Variable | Purpose |
+| ------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
+| `SNUFFLE_APM_URL` | Base URL of Snuffle. Empty turns the endpoint off and it answers `501`. |
+| `SNUFFLE_APM_USER` / `SNUFFLE_APM_PASSWORD` | ClickHouse credential that Snuffle uses. Defaults to the logs cluster user. Prefer a read-only user. |
+| `SNUFFLE_APM_TIMEOUT_SECONDS` | Upstream request timeout. Default `60`. |
diff --git a/posthog/api/snuffle_proxy.py b/posthog/api/snuffle_proxy.py
index 36e8ee7f3cb5..f63272d41f2e 100644
--- a/posthog/api/snuffle_proxy.py
+++ b/posthog/api/snuffle_proxy.py
@@ -76,7 +76,7 @@ class SnuffleProxyViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):
if not any(pattern.fullmatch(path) for pattern in self.allowed_paths):
return _error_response(status.HTTP_404_NOT_FOUND, "not_found", f"unsupported endpoint: {path}")
- base_url = settings.SNUFFLE_URL
+ base_url = settings.SNUFFLE_APM_URL
if not base_url:
return _error_response(
status.HTTP_501_NOT_IMPLEMENTED, "unavailable", "PromQL/LogQL query API is not configured"
@@ -88,7 +88,7 @@ class SnuffleProxyViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):
params = _forwardable(request.query_params)
headers = {TEAM_ID_HEADER: str(team_id), "Accept": request.headers.get("Accept", "application/json")}
body = _forwardable(request.data) if method == "POST" and isinstance(request.data, QueryDict) else None
- auth = (settings.SNUFFLE_USER, settings.SNUFFLE_PASSWORD) if settings.SNUFFLE_USER else None
+ auth = (settings.SNUFFLE_APM_USER, settings.SNUFFLE_APM_PASSWORD) if settings.SNUFFLE_APM_USER else None
try:
upstream = internal_requests.request(
@@ -98,7 +98,7 @@ class SnuffleProxyViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):
data=body,
headers=headers,
auth=auth,
- timeout=settings.SNUFFLE_TIMEOUT_SECONDS,
+ timeout=settings.SNUFFLE_APM_TIMEOUT_SECONDS,
)
except requests.Timeout:
logger.warning("snuffle_proxy_timeout", team_id=team_id, path=path)
diff --git a/posthog/settings/data_stores.py b/posthog/settings/data_stores.py
index 09617a4ec49a..e611f1bae4d3 100644
--- a/posthog/settings/data_stores.py
+++ b/posthog/settings/data_stores.py
@@ -396,10 +396,10 @@ CLICKHOUSE_LOGS_ENABLE_STORAGE_POLICY: bool = get_from_env(
# Snuffle, the PromQL/LogQL bridge deployed next to the logs cluster, backs the Prometheus- and
# Loki-compatible query endpoints. Leaving the URL empty turns those endpoints off. Snuffle passes
# the Basic credential straight through to ClickHouse, so it defaults to the logs cluster user.
-SNUFFLE_URL: str = os.getenv("SNUFFLE_URL", "")
-SNUFFLE_USER: str = os.getenv("SNUFFLE_USER", CLICKHOUSE_LOGS_CLUSTER_USER)
-SNUFFLE_PASSWORD: str = os.getenv("SNUFFLE_PASSWORD", CLICKHOUSE_LOGS_CLUSTER_PASSWORD)
-SNUFFLE_TIMEOUT_SECONDS: int = get_from_env("SNUFFLE_TIMEOUT_SECONDS", 60, type_cast=int)
+SNUFFLE_APM_URL: str = os.getenv("SNUFFLE_APM_URL", "")
+SNUFFLE_APM_USER: str = os.getenv("SNUFFLE_APM_USER", CLICKHOUSE_LOGS_CLUSTER_USER)
+SNUFFLE_APM_PASSWORD: str = os.getenv("SNUFFLE_APM_PASSWORD", CLICKHOUSE_LOGS_CLUSTER_PASSWORD)
+SNUFFLE_APM_TIMEOUT_SECONDS: int = get_from_env("SNUFFLE_APM_TIMEOUT_SECONDS", 60, type_cast=int)
CLICKHOUSE_KAFKA_NAMED_COLLECTION: str = os.getenv("CLICKHOUSE_KAFKA_NAMED_COLLECTION", "msk_cluster")
CLICKHOUSE_KAFKA_WARPSTREAM_INGESTION_NAMED_COLLECTION: str = os.getenv(
diff --git a/products/logs/backend/test/test_loki_api.py b/products/logs/backend/test/test_loki_api.py
index a8a2d1632e50..1090d6396a3d 100644
--- a/products/logs/backend/test/test_loki_api.py
+++ b/products/logs/backend/test/test_loki_api.py
@@ -10,11 +10,11 @@ from rest_framework import status
from posthog.models.personal_api_key import PersonalAPIKey
from posthog.models.utils import generate_random_token_personal, hash_key_value
-SNUFFLE_SETTINGS = {
- "SNUFFLE_URL": "http://snuffle.test:9091/",
- "SNUFFLE_USER": "reader",
- "SNUFFLE_PASSWORD": "secret",
- "SNUFFLE_TIMEOUT_SECONDS": 12,
+SNUFFLE_APM_SETTINGS = {
+ "SNUFFLE_APM_URL": "http://snuffle.test:9091/",
+ "SNUFFLE_APM_USER": "reader",
+ "SNUFFLE_APM_PASSWORD": "secret",
+ "SNUFFLE_APM_TIMEOUT_SECONDS": 12,
}
@@ -26,7 +26,7 @@ def _upstream(status_code: int = 200, body: bytes = b'{"status":"success","data"
return response
-@override_settings(**SNUFFLE_SETTINGS)
+@override_settings(**SNUFFLE_APM_SETTINGS)
class TestLokiQueryApi(APIBaseTest):
def setUp(self):
super().setUp()
@@ -106,7 +106,7 @@ class TestLokiQueryApi(APIBaseTest):
assert response.json()["status"] == "error"
self.request_mock.assert_not_called()
- @override_settings(SNUFFLE_URL="")
+ @override_settings(SNUFFLE_APM_URL="")
def test_unconfigured_returns_501(self):
response = self.client.get(f"{self.base}/query", {"query": '{a="b"}'})
diff --git a/products/metrics/backend/tests/test_prometheus_api.py b/products/metrics/backend/tests/test_prometheus_api.py
index edab1d0b098d..3feb2b8918b6 100644
--- a/products/metrics/backend/tests/test_prometheus_api.py
+++ b/products/metrics/backend/tests/test_prometheus_api.py
@@ -19,7 +19,7 @@ def _upstream() -> MagicMock:
return response
-@override_settings(SNUFFLE_URL="http://snuffle.test:9091", SNUFFLE_USER="reader", SNUFFLE_PASSWORD="secret")
+@override_settings(SNUFFLE_APM_URL="http://snuffle.test:9091", SNUFFLE_APM_USER="reader", SNUFFLE_APM_PASSWORD="secret")
class TestPrometheusQueryApi(APIBaseTest):
def setUp(self):
super().setUp()