clp-json includes an API server that provides a RESTful interface for interacting with CLP.
:::{note}
Currently, the API server only supports clp-json. Support for clp-text will be
added in a future release.
:::
CLP starts the API server based on the api_server section in etc/clp-config.yaml, which includes
a default configuration. You can uncomment and modify this section to override the defaults.
All available API endpoints are defined in the OpenAPI Specification. You can explore the API using Swagger UI.
The API server exposes endpoints to submit search queries, and returns search results as a continuous stream using Server-sent Events.
Assuming the server is running on the default host and port (localhost:3001), you can use the
following commands to submit a query to clp-json and stream the results.
-
Submit a search query:
curl -X POST http://localhost:3001/query \ -H "Content-Type: application/json" \ -d '{ "query_string": "*log*", "datasets": ["default"], "ignore_case": false, "max_num_results": 100 }'On success, the server responds with:
{ "query_results_uri": "/query_results/100" } -
Retrieve search results: Use the returned
query_results_urito receive search results as an SSE stream:curl -N http://localhost:3001/query_results/100
Example streamed output:
data: {"timestamp": 1767225600000, "message": "Example log message"} data: {"timestamp": 1767225600010, "message": "Another matched log line"} data: {"timestamp": 1767225600020, "message": "No logs found" }