Observability: Monitoring, logging, and tracing sample - Go

    1. A Kubernetes cluster with Knative Serving installed and DNS configured.
    2. Check if Knative monitoring components are installed:
    • If pods aren’t found, install .
    1. Install Docker.

    Setup

    Build the application container and publish it to a container registry:

    1. Move into the sample directory:
    1. cd $GOPATH/src/github.com/knative/docs
    1. Set your preferred container registry:
    1. export REPO="gcr.io/<YOUR_PROJECT_ID>"

    This example shows how to use Google Container Registry (GCR). You will need a Google Cloud Project and to enable the Google Container Registry API.

    1. Use Docker to build your application container:
    1. docker build \
    2. --tag "${REPO}/docs/serving/samples/telemetry-go" \
    3. --file=docs/serving/samples/telemetry-go/Dockerfile .
    1. Push your container to a container registry:
    1. Replace the image reference path with our published image path in the configuration file (docs/serving/samples/telemetry-go/sample.yaml):

      • Manually replace: image: github.com/knative/docs/docs/serving/samples/telemetry-go with

      • Use run this command:

      Deploy the Service

      Deploy this application to Knative Serving:

      1. kubectl apply --filename docs/serving/samples/telemetry-go/

      Inspect the created resources with the kubectl commands:

      • View the created Route resource:
      1. kubectl get route --output yaml
      • View the created Configuration resource:
      1. kubectl get configurations --output yaml
      • View the Revision that was created by the Configuration:

      Access the Service

      To access this service via curl, you need to determine its ingress address.

      1. To determine if your route is ready:
      1. kubectl get route
      1. Make a request to the service to see the Hello World! message:
      1. curl http://telemetrysample-route.default.example.com
      1. Make a request to the /log endpoint to generate logs to the stdout file and generate files under /var/log in both JSON and plain text formats:
      1. curl http://telemetrysample-route.default.example.com/log

      Access Logs

      You can access to the logs from Kibana UI - see Logs for more information.

      You can access to per request traces from Zipkin UI - see for more information.

      Accessing Custom Metrics

      You can see published metrics using Prometheus UI. To access to the UI, forward the Prometheus server to your machine:

      Then browse to .

      Clean up