Table of Contents | ||||
---|---|---|---|---|
|
Use the CDAP Logging Microservices to download the logs of applications and the system, with the option of formatting and filtering the logs that are downloaded, and setting the log levels of programs at runtime when under Distributed CDAP mode.
Additional details on logging can be found in Logging and Monitoring.
All methods or endpoints described in this API have a base URL (typically http://<host>:11015
or https://<host>:10443
) that precedes the resource identifier, as described in the Microservices Conventions. These methods return a status code, as listed in the Microservices Status Codes.
...
Code Block |
---|
GET /v3/namespaces/<namespace-id>/apps/<app-id>/<program-type>/<program-id>/logs?start=<ts>&stop=<ts>&filter=loglevel=<logLevel> |
Parameter | Description |
---|---|
| Namespace ID |
| Name of the application being called |
| One of |
| Name of the program being called |
| Start and stop times, given as seconds since the start of the Epoch. |
| One of |
Example
HTTP Method |
|
---|---|
Description | Return the logs for all the events from the flow WordCountTracker of the WordCount application in the namespace default, beginning |
Downloading Application Logs for a Run
...
Code Block |
---|
GET /v3/namespaces/<namespace-id>/apps/<app-id>/<program-type>/<program-id>/runs/<run-id>/logs?start=<ts>&stop=<ts> |
Parameter | Description |
---|---|
| Namespace ID |
| Name of the application being called |
| One of |
| Name of the program being called |
| Run id of the program run |
| Start and stop times, given as seconds since the start of the Epoch. |
Example
HTTP Method |
|
---|---|
Description | Return the logs for all the events from the flow WordCountTracker of the WordCount application in the namespace default for run c826e692-ef8c-11e4-953d-d6686e126da6, beginning |
Downloading System Logs
Logs emitted by a system service running in CDAP can be downloaded with the Logging HTTP API. To do that, send an HTTP GET request:
Code Block |
---|
GET /v3/system/services/<service-id>/logs?start=<ts>&stop=<ts> |
where:
Parameter | Description |
---|---|
| One of |
| Start and stop times, given as seconds since the start of the Epoch. |
Note that the start and stop times are not optional.
Example
HTTP Method |
|
---|---|
Description | Return the logs for the AppFabric service beginning |
Formatting and Filtering
Formatting
...
Code Block |
---|
2013-10-23 18:03:09,793 - INFO [FlowletProcessDriver-source-0-executor:c.c.e.c.StreamSource@-1] – source: Emitting line: this is an & character |
Note: The context of the log line shows the name of the flowlet (source), its instance number (0) as well as the original line in the application code. The character & is escaped as &
; if you don’t desire this escaping, you can turn it off by adding the parameter &escape=false
to the request URL.
The text can also be formatted as JSON. To do so, suffix your URL with the parameter &format=json
.
...
Code Block |
---|
'{ "io.cdap.cdap":"ERROR", "ROOT":"TRACE" }' |
Parameter | Description |
---|---|
| One of |
Note that changing the log levels of the appfabric
service will also change the log levels of the dataset.service
as they run on the same node.
...
If the body is not provided or is empty, it will reset the log levels of all logger names.
Parameter | Description |
---|---|
| One of |
Note that resetting the log levels of the appfabric
service will also rest the log levels of the dataset.service
as they run on the same node.
...
Code Block |
---|
'{ "io.cdap.cdap":"ERROR", "ROOT":"TRACE" }' |
Parameter | Description |
---|---|
| Namespace ID |
| Name of the application |
| Version of the application |
| One of |
| Name of the program |
| UUID of the program run |
For example:
Code Block |
---|
PUT /v3/namespaces/default/apps/SportResults/services/UploadService/run-id/cdec1791-c2c0-11e6-ac6b-42010a800022/loglevels \ -d '{ "io.cdap.cdap":"ERROR", "ROOT":"TRACE" }' |
...
Code Block |
---|
PUT /v3/namespaces/<namespace-id>/apps/<app-id>/versions/<app-version>/<program-type>/<program-id>/runs/<run-id>/loglevels |
Path Parameters
Parameter | Description |
---|---|
| Namespace ID |
| Name of the application |
| Version of the application |
| One of |
| Name of the program |
| UUID of the program run |
JSON Parameters
Parameter | Description |
---|---|
| Name of the logger. |
| Log level ( For example, if you pass the JSON input: |
Resetting Program Log Levels
...
If the body is not provided or is empty, it will reset the log levels of all logger names.
Parameter | Description |
---|---|
| Namespace ID |
| Name of the application |
| Version of the application |
| One of |
| Name of the program |
| UUID of the program run |
For example:
Code Block |
---|
POST /v3/namespaces/default/apps/SportResults/services/UploadService/run-id/cdec1791-c2c0-11e6-ac6b-42010a800022/resetloglevels \ -d '[ "io.cdap.cdap", "ROOT" ]' |
...
Code Block |
---|
POST /v3/namespaces/<namespace-id>/apps/<app-id>/versions/<app-version>/<program-type>/<program-id>/runs/<run-id>/resetloglevels |
Path Parameters
Parameter | Description |
---|---|
| Namespace ID |
| Name of the application |
| Version of the application |
| One of |
| Name of the program |
| UUID of the program run |
JSON Parameters
Parameter | Description |
---|---|
| Name of the logger. |
loglevel | Log level ( For example, if you pass the JSON input: |