Viewing Logs

Anchore services produce detailed logs that container information about user interactions, internal processes, warnings and errors. The verbosity of the logs is controlled using the log_level setting in config.yaml (for manual installations) or the corresponding ANCHORE_LOG_LEVEL environment variable (for docker compose or Helm installations) for each service.

The log levels are DEBUG, INFO, WARN, ERROR, and FATAL, where the default is INFO. Most of the time, the default level is sufficient as the logs will container WARN, ERROR and FATAL messages as well. But for deep troubleshooting, it is always recommended to increase the log level to DEBUG in order to ensure the availability of the maximum amount of information.

Anchore logs can be accessed by inspecting the docker logs for any anchore service container using the regular docker logging mechanisms, which typically default to displaying to the stdout/stderr of the containers themselves - for example:

# docker ps
...
33c809f1803a        anchore/anchore-engine:latest       "/docker-entrypoint.…"   22 hours ago        Up 22 hours (healthy)   8228/tcp                         aevolume_engine-catalog_1
...

# docker logs aevolume_engine-analyzer_1
[service:worker] 2019-12-06 00:54:20+0000 [-] [MainThread] [anchore_engine.twisted/makeService()] [INFO] Initializing configuration
[service:worker] 2019-12-06 00:54:20+0000 [-] [MainThread] [anchore_engine.twisted/makeService()] [INFO] Initializing logging
[service:worker] 2019-12-06 00:54:20+0000 [-] [MainThread] [anchore_engine.service/initialize()] [DEBUG] Invoking instance-specific handler registration
[service:worker] 2019-12-06 00:54:20+0000 [-] [MainThread] [anchore_engine.service/_register_instance_handlers()] [INFO] Registering api handlers
[service:worker] 2019-12-06 00:54:20+0000 [-] [MainThread] [anchore_engine.service/_process_stage_handlers()] [INFO] Processing init handlers for bootsrap stage: pre_config
[service:worker] 2019-12-06 00:54:20+0000 [-] [MainThread] [anchore_engine.service/_process_stage_handlers()] [DEBUG] Executing 0 stage pre_config handlers
[service:worker] 2019-12-06 00:54:20+0000 [-] [MainThread] [anchore_engine.service/_configure()] [INFO] Loading and initializing global configuration
[service:worker] 2019-12-06 00:54:20+0000 [-] [MainThread] [anchore_engine.service/_configure()] [INFO] Configuration complete
...
...

The logs themselves are also persisted as logfiles inside the Anchore service containers. Executing a shell into any Anchore service container and navigating to /var/log/anchore, you will find the service log files. For example, using the same analyzer container service as described previously.

# docker exec -t -i  aevolume_engine-analyzer_1 /bin/bash
[anchore@687818c10b93 anchore-engine]$ cat /var/log/anchore/anchore-worker.log
2019-12-06 00:54:20+0000 [-] [MainThread] [anchore_engine.twisted/makeService()] [INFO] Initializing configuration
2019-12-06 00:54:20+0000 [-] [MainThread] [anchore_engine.twisted/makeService()] [INFO] Initializing logging
2019-12-06 00:54:20+0000 [-] [MainThread] [anchore_engine.service/initialize()] [DEBUG] Invoking instance-specific handler registration
2019-12-06 00:54:20+0000 [-] [MainThread] [anchore_engine.service/_register_instance_handlers()] [INFO] Registering api handlers
2019-12-06 00:54:20+0000 [-] [MainThread] [anchore_engine.service/_process_stage_handlers()] [INFO] Processing init handlers for bootsrap stage: pre_config
2019-12-06 00:54:20+0000 [-] [MainThread] [anchore_engine.service/_process_stage_handlers()] [DEBUG] Executing 0 stage pre_config handlers
2019-12-06 00:54:20+0000 [-] [MainThread] [anchore_engine.service/_configure()] [INFO] Loading and initializing global configuration
2019-12-06 00:54:20+0000 [-] [MainThread] [anchore_engine.service/_configure()] [INFO] Configuration complete
...
...

If you are using Kubernetes to run Anchore Enterprise, you can retrieve the logs from the service pods directly using kubectl commands:

Tip: You can find the desired pod name with kubectl get pods

# k8s-inventory kubectl logs -n <your-namespace> <your-anchore-pod-name>
[uvicorn:anchore-enterprise-apiext] [2024-06-05T19:26:51.508107+00:00] [MainProcess] [MainThread] [INFO] [asyncio.runners/run():190] | 10.244.1.1:55706 - "GET /health HTTP/1.1" 200
[uvicorn:anchore-enterprise-apiext] [2024-06-05T19:26:54.080546+00:00] [MainProcess] [MainThread] [INFO] [asyncio.runners/run():190] | 10.244.1.2:56838 - "GET /health HTTP/1.1" 200
[uvicorn:anchore-enterprise-apiext] [2024-06-05T19:26:54.085999+00:00] [MainProcess] [MainThread] [INFO] [asyncio.runners/run():190] | 10.244.1.2:56854 - "GET /health HTTP/1.1" 200
[uvicorn:anchore-enterprise-apiext] [2024-06-05T19:26:54.089404+00:00] [MainProcess] [MainThread] [INFO] [asyncio.runners/run():190] | 10.244.1.2:56860 - "GET /version HTTP/1.1" 200
[uvicorn:anchore-enterprise-apiext] [2024-06-05T19:26:56.773285+00:00] [MainProcess] [MainThread] [INFO] [asyncio.runners/run():190] | 10.244.1.1:46424 - "GET /health HTTP/1.1" 200
[uvicorn:anchore-enterprise-apiext] [2024-06-05T19:27:00.508614+00:00] [MainProcess] [MainThread] [INFO] [asyncio.runners/run():190] | 10.244.1.5:59244 - "POST /v2/kubernetes-inventory HTTP/1.1" 201
Last modified June 28, 2024