Request logging
Request logging is disabled by default. This topic describes how to configure Druid to generate request logs to track query metrics.
To enable request logging, determine the type of request logger to use, then set the configurations specific to the request logger type.
The following request logger types are available:
- : Disables request logging, the default behavior.
- : Stores logs to disk.
- emitter: Logs request to an external location, which is configured through an emitter.
- : Logs queries via the SLF4J Java logging API.
- filtered: Filters requests by query type or execution time before logging the filtered queries by the delegated request logger.
- : Logs all requests to multiple request loggers.
- switching: Logs native queries and SQL queries to separate request loggers.
Druid stores the results in the Broker logs, unless the request logging type is emitter
. If you use emitter request logging, you must also configure metrics emission.
Druid includes various emitters to send metrics and alerts. To emit query metrics, set druid.request.logging.feed=emitter
, and define the emitter type in the druid.emitter
property.
You can use any of the following emitters in Druid:
noop
: Disables metric emission, the default behavior.- logging: Emits metrics to Log4j 2. See to configure Log4j 2 for use with Druid.
- http: Sends HTTP
POST
requests containing the metrics in JSON format to a user-defined endpoint. - : Operates like the
http
emitter but fine-tunes the recipient URL based on the event feed. - composing: Emits metrics to multiple emitter types.
- : Emits metrics to a Graphite Carbon service.
The following configuration shows how to enable request logging and post query metrics to the endpoint http://example.com:8080/path
.
The following shows an example log emitter output:
[
{
"feed": "metrics",
"timestamp": "2022-01-06T20:32:06.628Z",
"service": "druid/broker",
"host": "localhost:8082",
"version": "2022.01.0-iap-SNAPSHOT",
"metric": "sqlQuery/bytes",
"value": 9351,
"dataSource": "[wikipedia]",
"id": "56e8317b-31cc-443d-b109-47f51b21d4c3",
"nativeQueryIds": "[2b9cbced-11fc-4d78-a58c-c42863dff3c8]",
"remoteAddress": "127.0.0.1",
"success": "true"
},
{
"feed": "myRequestLogFeed",
"timestamp": "2022-01-06T20:32:06.585Z",
"remoteAddr": "127.0.0.1",
"service": "druid/broker",
"sqlQueryContext":
{
"useApproximateCountDistinct": false,
"sqlQueryId": "56e8317b-31cc-443d-b109-47f51b21d4c3",
"useApproximateTopN": false,
"useCache": false,
"sqlOuterLimit": 101,
"populateCache": false,
"nativeQueryIds": "[2b9cbced-11fc-4d78-a58c-c42863dff3c8]"
},
"queryStats":
{
"sqlQuery/time": 43,
"sqlQuery/planningTimeMs": 5,
"sqlQuery/bytes": 9351,
"success": true,
"context":
{
"useApproximateCountDistinct": false,
"useApproximateTopN": false,
"useCache": false,
"populateCache": false,
"nativeQueryIds": "[2b9cbced-11fc-4d78-a58c-c42863dff3c8]"
},
"identity": "allowAll"
},
"query": null,
"host": "localhost:8082",
"sql": "SELECT * FROM wikipedia WHERE cityName = 'Buenos Aires'"
},
{
"feed": "myRequestLogFeed",
"timestamp": "2022-01-06T20:32:07.652Z",
"remoteAddr": "",
"service": "druid/broker",
"sqlQueryContext":
{},
"queryStats":
{
"query/time": 16,
"query/bytes": -1,
"success": true,
"identity": "allowAll"
},
"query":
{
"queryType": "scan",
"dataSource":
{
"type": "table",
"name": "wikipedia"
},
"intervals":
{
"type": "intervals",
"intervals":
[
"-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z"
]
},
"virtualColumns":
[
{
"type": "expression",
"name": "v0",
"expression": "'Buenos Aires'",
"outputType": "STRING"
}
],
"resultFormat": "compactedList",
"batchSize": 20480,
"limit": 101,
"filter":
"dimension": "cityName",
"value": "Buenos Aires",
"extractionFn": null
},
"columns":
[
"__time",
"added",
"channel",
"comment",
"commentLength",
"countryIsoCode",
"countryName",
"deleted",
"delta",
"deltaBucket",
"diffUrl",
"flags",
"isAnonymous",
"isMinor",
"isNew",
"isRobot",
"isUnpatrolled",
"metroCode",
"namespace",
"page",
"regionIsoCode",
"regionName",
"user",
"v0"
],
"legacy": false,
"context":
{
"populateCache": false,
"queryId": "62e3d373-6e50-41b4-873b-1e56347c2950",
"sqlOuterLimit": 101,
"sqlQueryId": "cbb3d519-aee9-4566-8920-dbbeab6269f5",
"useApproximateCountDistinct": false,
"useApproximateTopN": false,
"useCache": false
},
"descending": false,
"granularity":
{
"type": "all"
}
},
"host": "localhost:8082",
"sql": null
},
]
See the following topics for more information.