Where Do I Find My Agent's Logs?

To investigate agent failure or diagnose any agent connectivity issues, enable the agent log. You can view the logs and debug issues in real time. You may need to provide the Agent ID and the Location ID. For more information, see Enabling and Downloading Agent Log.

Docker Installation Logs

To find the logs for your agent, you need to do the following:

  1. Log in to the machine that contains the agent and run the following command to list all the containers:
    $ sudo docker ps -a
    You should see something similar to the following:
    CONTAINER ID   IMAGE                    COMMAND                 CREATED      STATUS      PORTS  NAMES
    8af1a5d84e16 blazemeter/crane:1.0.98 "python agent/agent.…" 5 weeks ago Up 5 weeks bzm-crane-<AGENT_ID>
  2. Grab the Container ID for the bzm-crane-<AGENT_ID> container and run the following command:

    Full container log displayed
    $ sudo docker logs <Container ID>
    OR

    Full container log saved to a file
    $ sudo docker logs <Container ID> >& <Your Filename>
    OR

    Get last X amount of lines of the log
    $ sudo docker logs --tail <No. of Lines from the end of log> <Container ID>
    OR
    $ sudo docker logs --tail <No. of Line from end of log> <Container ID> >& <Your Filename>
  3. You can get more specific with the docker logs command by following the documentation on Docker's website.

Kubernetes Installation Logs

To find the logs for your agent, you need to do the following:

  1. Log in to the Kubernetes instance that contains the agent (also known as ship) and run the following command to list all the pods:
    $ kubectl get pods
    You should see something similar to the following:
    NAME                   READY  STATUS   RESTARTS  AGE
    crane-9bcf79ddf-sj7cg 1/1 Running 9 3d
  2. Grab the pod name for the crane pod and run the following command:

    Full container log displayed
    $ kubectl logs <crane pod name>
    OR

    Full container log saved to a file
    $ kubectl logs <crane pod name> >& <Your Filename>
    OR

    Get last X amount of lines of the log
    $ kubectl logs <pod name> --tail=<no. of lines>
    OR
    $ kubectl logs <pod name> --tail=<no. of lines> >& <Your Filename>
  3. If you need the events of the pod (such as trying to see what happened with the changing status of the pod), you can use the following command:
     $ kubectl describe pod <pod name>
    You will get a response like the following:
    Name:               crane-9bcf79ddf-sj7cg
    Namespace:          default
    Priority:           0
    PriorityClassName:  
    Node:               ${node info}
    Start Time:         Mon, 13 Jan 2020 14:34:44 -0600
    Labels:             pod-template-hash=9bcf79ddf
                        role=role-crane
    Annotations:        kubernetes.io/limit-ranger: LimitRanger plugin set: cpu request for container crane-container
    Status:             Running
    IP:                 10.48.2.2
    Controlled By:      ReplicaSet/crane-9bcf79ddf
    Containers:
      crane-container:
        Container ID:   docker://6ed55b2f57167aae43ba4781044fe441f2fcd4aa11d76c8228d66c280dca89ee
        Image:          gcr.io/verdant-bulwark-278/blazemeter/crane:latest-master
        Image ID:       docker-pullable://gcr.io/verdant-bulwark-278/blazemeter/crane@sha256:1d69e536a210d870d3099fba8a9d52330a0611f856210509a7eb1b681fd0d356
        Port:           
        Host Port:      
        State:          Running
          Started:      Mon, 13 Jan 2020 14:37:54 -0600
        Last State:     Terminated
          Reason:       Error
          Exit Code:    255
          Started:      Mon, 13 Jan 2020 14:36:19 -0600
          Finished:     Mon, 13 Jan 2020 14:36:21 -0600
        Ready:          True
        Restart Count:  5
        Requests:
          cpu:  100m
        Environment:
          AUTH_TOKEN:              ${auth_token}
          HARBOR_ID:               ${location_id}
          SHIP_ID:                 ${agent_id}
          CONTAINER_MANAGER_TYPE:  KUBERNETES
          IMAGE_OVERRIDES:         {}
          DOCKER_REGISTRY:         gcr.io/verdant-bulwark-278
          AUTO_KUBERNETES_UPDATE:  true
        Mounts:
          /var/run/secrets/kubernetes.io/serviceaccount from default-token-7qjt2 (ro)
    Conditions:
      Type              Status
      Initialized       True 
      Ready             True 
      ContainersReady   True 
      PodScheduled      True 
    Volumes:
      default-token-7qjt2:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  default-token-7qjt2
        Optional:    false
    QoS Class:       Burstable
    Node-Selectors:  
    Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                     node.kubernetes.io/unreachable:NoExecute for 300s
    Events:
      Type     Reason     Age                    From                                                    Message
      ----     ------     ----                   ----                                                    -------
      Normal   Scheduled  4m9s                   default-scheduler                                       Successfully assigned default/crane-9bcf79ddf-sj7cg to gke-travis-new-opl-default-pool-43e3521b-l3l6
      Normal   Started    3m18s (x4 over 4m5s)   kubelet, ${node}                                        Started container
      Warning  BackOff    2m50s (x6 over 3m59s)  kubelet, ${node}                                        Back-off restarting failed container
      Normal   Pulling    2m35s (x5 over 4m8s)   kubelet, ${node}                                        pulling image "gcr.io/verdant-bulwark-278/blazemeter/crane:3.2.6-1595"
      Normal   Pulled     2m34s (x5 over 4m6s)   kubelet, ${node}                                        Successfully pulled image "gcr.io/verdant-bulwark-278/blazemeter/crane:3.2.6-1595"
      Normal   Created    2m34s (x5 over 4m5s)   kubelet, ${node}                                        Created container
You can get more specific with the Kubernetes logs command by following the documentation on Kubernetes's website here.