Prerequisites
- Nightingale v9.3.0, with permission to add a data source and create an alert rule in a business group.
- A ClickHouse service reachable from the Nightingale server and, if used, the edge alert engine that runs the rule.
- A ClickHouse user with
SELECTon the table the rule reads. For the example, you also need a separate account that can create the table and insert sample data.
Native TLS on port
9440 is included as a configuration reference.
Authentication and privileges
Use a dedicated database user with a password over TLS and grantSELECT on the table or view used by the rule. For the example, prepare the sample data first, then run these statements as a ClickHouse administrator. Replace the example password before running them.
nightingale_reader in the data source. Run the example’s CREATE and INSERT statements with a separate privileged account.
Connect Nightingale to ClickHouse
In Nightingale, open Integrations → Data sources → Add and select ClickHouse. Enter a name and provide the ClickHouse User and Password for the read-only account. In Nodes, enter onehost:port without a URL scheme or path. In Associated alerting engine cluster, select the cluster that runs the rule. Use default for a single-engine installation with the default configuration.
- ClickHouse Cloud
- Self-managed ClickHouse
Open your service in the Cloud console and select Connect. Copy the service hostname and use the port for your chosen protocol. Turn on Secure connection (SSL/TLS) and leave Skip SSL verify off.
If the service restricts incoming connections, allow the Nightingale server or alert engine’s egress IP. Use database credentials for the service. Cloud connection details · IP filters
SHOW DATABASES connection check. Then use the rule editor’s Preview to verify the account can read the target table and return the expected columns.
Alert on recent HTTP errors
Prepare the sample data
Create a table and add a baseline. The twelve old errors fall outside the rule’s one-minute window. The recent200 response is inside the window but does not count as an error.
Build and preview the rule
In Alerts & Notifications → Alert rules, add a rule in your business group. Choose ClickHouse as the data source type and select the data source you saved. Paste this SQL as queryA.
error_count and Label field to service. Click Preview and check that query A returns 0 with the label service=checkout.
Set the trigger expression to $A.error_count >= 10 and choose a severity. Set the evaluation interval to 15 seconds, use zero trigger and recovery delay, and keep the default recovery behavior. The interval controls when Nightingale runs the query. The WHERE clause sets the one-minute lookback window.
Verify firing and recovery
Enable the rule and wait for an evaluation record showing0.
Insert twelve recent errors using the privileged account.
12 and the rule should create a current event with service=checkout. Stop inserting errors and wait for the window to pass. The same query returns 0, so the rule should recover on the next evaluation and record the recovery in historical events. The aggregate returns a row with the same label even when the window is empty. A notification channel is optional for inspecting these events.
In the Cloud test, Nightingale verified the data source when saving it. The scheduled rule evaluated the 25-row fixture from 0 to 12 and back to 0. The firing and recovery records shared the same rule, service=checkout label, and event hash.
Disable or delete the demo rule when finished. See Nightingale’s SQL-backed rules guide for rule settings.
Keep scheduled queries bounded
- Filter on a sorting or partition key where possible. In the example, the
WHEREclause restricts bothserviceandevent_timeto match the table’sORDER BYkey. - Aggregate to one row per label set you want to evaluate. Return the numeric values and label columns the rule uses.
- Measure query time with the same account and a representative time window before choosing an evaluation interval. For costly queries that need frequent evaluation, point the rule at a pre-aggregated table.
Known limits
- In the open-source edition, the ClickHouse data source is available only in the SQL alert-rule editor.
- Nightingale uses the first entry in Nodes. Point it at a service endpoint if your deployment needs failover.
- The data source form supports password authentication only.
- Use a finite scalar number for the value field. A complex value such as an array, tuple, or map cannot be compared directly. Aggregate it or extract a number in SQL. Values are converted to
Float64, so very large integers can lose precision. - The default result limit is 500 rows. Nightingale first counts the rows in a subquery and rejects results above the configured cap. The Cloud check returned 500 points for a 500-row query and rejected a 501-row query. Use the SQL predicates to bound how much data ClickHouse reads.
Troubleshooting
- Connection or TLS test fails. Verify the protocol and listener port, the network path from Nightingale, and any Cloud IP filters. For certificate errors, verify the hostname and trust chain. Keep certificate verification enabled.
- Connection test succeeds but the query fails. Check the table grant, use a fully qualified name such as
n9e_demo.requests, and verify the SQL with the same read-only account. - Preview succeeds but the rule has no evaluation records. Check that the rule is enabled and the data source is associated with a running alerting engine cluster.
- The rule does not fire or recover as expected. Inspect the rule’s evaluation records for the query value and label. Check the time window, the exact alias in Value field, and the expression reference. A grouped query can drop a label when the group is absent. If that should keep the alert firing, select the Recovery configuration option that requires data and a trigger condition that is no longer met.