Setting Up a Learning Environment with Demo Applications
local graph
Chapter 3 — Setting Up a Learning Environment with Demo Applications
Section titled “Chapter 3 — Setting Up a Learning Environment with Demo Applications”This chapter guides you through setting up a learning environment for the practical examples throughout this book and for independent experimentation. As Grafana Labs offers a free tier of their cloud service, we will use this for the storage and searching of data. To produce rich, useful data, we will use the OpenTelemetry demo application. This demo application deploys the services needed to run the OpenTelemetry Astronomy Shop locally. These applications are written in many different languages and are instrumented to produce metrics, logs, and distributed traces. This application will help you interact directly (and via load generators) with real applications and see observability telemetry in real time in the Grafana Labs instance.
In this chapter, we’re going to cover the following main topics:
- Introducing Grafana Cloud
- Installing the prerequisite tools
- Installing the OpenTelemetry Demo application
- Exploring telemetry from the demo application
- Troubleshooting your OpenTelemetry demo application
Technical requirements
Section titled “Technical requirements”We assume you are working on at least Windows 10 version 2004, macOS version 11, or a relatively recent installation of Linux (e.g., Ubuntu 20.10 or later); earlier versions are not supported. We will be using the OpenTelemetry Collector version 0.73.1 and the OpenTelemetry Demo version 0.26.0. Full installation instructions for these components are provided in this chapter.
All commands and configuration files to complete these steps are included in the GitHub repository at https://github.com/PacktPublishing/Observability-with-Grafana/tree/main/chapter3. You’ll find the Code in Action videos for this chapter at
Introducing Grafana Cloud
Section titled “Introducing Grafana Cloud”Grafana Cloud is a hosted platform-as-a-service observability tool. It offers the ability to quickly create infrastructure to receive and store log, metric, and trace data as well as tools to visualize the data. We are using Grafana Cloud to reduce the technical skill needed to engage with this book, although all the open source components from Grafana that we will introduce can be deployed locally as well.
Grafana Cloud offers free access. In this chapter, we will first set up a cloud account and familiarize ourselves with the administration and use of the tools.
Important note
Grafana Labs introduces changes on a regular basis. The information and screenshots in this chapter are based on Grafana version 10.2, which was released in October 2023.
Setting up an account
Section titled “Setting up an account”Creating a free Grafana Cloud account is simple. To do this, follow these steps:
- Go to https://www.grafana.com and click on Create Free Account.
- Sign up using any of the following:
- A Google account 2. A GitHub account 3. A Microsoft account 4. An Amazon account 5. An email address
- Choose a team URL. This is the URL used to access your Grafana instance. In our sample setup, we chose
observabilitywithgrafana:
Figure 3.1 – Creating a Grafana stack
- Choose a deployment region from the available list and then wait for a few minutes for your Grafana account to be created.
- When the account creation is completed, you will see a screen titled GET STARTED, as shown in the following screenshot. We encourage you to explore the screens in Grafana, but for this introduction, you can just click on I’m already familiar with Grafana:

Figure 3.2 – Get started with Grafana
Then click on the Grafana icon in the top-left corner to return to the home screen, and finally, click on Stacks, which you will find just under the welcome message:

Figure 3.3 – Welcome to Grafana Cloud
- This will take you to the Grafana Cloud Portal, which will look like this.

Figure 3.4 – The Grafana Cloud Portal
Before we set up the local data-producing environment, let’s take a few moments to explore the basics of the Grafana Cloud Portal and your new Grafana Stack.
Exploring the Grafana Cloud Portal
Section titled “Exploring the Grafana Cloud Portal”The home page of the portal shows your subscription and billing information, as well as details about your single Grafana Stack. When you first sign up for a Cloud Free subscription, you will be granted access to a 14-day trial for Cloud Pro. To access your instance of Grafana, you need to click on the Launch button in the Grafana section. This gives you access to view data you send to Grafana Cloud.
A full Grafana Stack consists of the following installations:
- Visualization:
- A Grafana instance
- Metrics:
- A Prometheus remote write endpoint
- A Graphite endpoint
- A Mimir backend storage instance
- A Prometheus remote write endpoint
- Logs:
- A Loki endpoint
- A Loki backend storage instance
- A Loki endpoint
- Traces:
- A Tempo endpoint
- A Tempo backend storage instance
- A Tempo endpoint
- Alerting:
- An Alerting instance for managing Prometheus-based alerts
- Load testing:
- A k6 cloud runner
- Profiling:
- A Pyroscope endpoint
- A Pyroscope backend storage instance
- A Pyroscope endpoint
Let’s take a look at some of the sections you can access in your portal:
- Security: In this section, you can manage access policies and access tokens, Open Authorization (OAuth), Security Assertion Markup Language (SAML), and Lightweight Directory Access Protocol (LDAP). Access policies are scoped to a realm; a realm can cover a specific stack, or it can cover the entire organization.
- Support: This section gives access to support from the community via Community Forums, and from Grafana Labs via Support Ticket and Chat with Support.
- Billing: The Billing section is where invoices and subscriptions are managed. A Cloud Free subscription provides a monthly limit of 10,000 metrics, 50 GB logs and 50 GB traces, 50 GB profiles, as well as three Incident Response & Management (IRM) users and 500 k6 virtual user hours (VUh). This subscription is plenty for the demo applications we will be using during the book and similar small demo, personal-use installations. For larger installations, Grafana Cloud also offers two additional tiers, Cloud Pro and Cloud Advanced. These tiers give access to different key features, with Cloud Advanced being geared toward enterprise-level installations. Grafana then bills based on ingest and active users in different areas. Grafana provides a very easy-to-use monthly cost estimation tool:

Figure 3.5 – Grafana cost estimator
With a Cloud Free subscription, you will only have access to a single stack. With a subscription to Cloud Pro or Cloud Advanced, you will be able to create multiple stacks in your account. These stacks can be in different regions.
- Org Settings: Here, you can manage the users who can access Grafana Cloud. You can also update your avatar, organization name, and any plugins or dashboards you have shared with the community.
Now that you have explored the Grafana Cloud Portal and have an overview of managing a Grafana Cloud account, let’s explore the Grafana instance in your cloud stack.
Exploring the Grafana instance
Section titled “Exploring the Grafana instance”The main way to interact with the tools provided by the Grafana Stack is to access the Grafana instance. This instance provides visualization tools to view the data that is collected by the rest of the Grafana stack or other linked tools. To access your Grafana instance, you can click on the Launch button in your Cloud Portal:

Figure 3.6 – Launching Grafana
To access it more directly, you can use the direct URL based on the team name selected during account creation. For instance, our sample account has the URL https://observabilitywithgraf ana.grafana.net.
Once you have accessed Grafana, you will be greeted with a home page that shows your current usage. Navigation is done using the menu available at the top left of the page:

Figure 3.7 – The main navigation panel in Grafana
Let’s talk through the different sections available in the menu shown in the preceding figure.
Dashboards and Starred dashboards
Section titled “Dashboards and Starred dashboards”The Dashboards section allows you to create, import, organize, and tag dashboards in your Grafana installation. Under Dashboards, you can also access Playlists, Snapshot, Library panels, and Reporting:
- The Playlists subsection lets you manage groups of dashboards that are displayed in a sequence, for instance, on TVs in an office.
- The Snapshot tab gives you the ability to take a snapshot of a dashboard with the data to share. This will give the recipients the ability to explore the data much better than by sharing a simple screenshot.
- Library panels provides reusable panels that can be used in multiple dashboards to aid in offering a standardized UI.
- Finally, Reporting allows you to automatically generate PDFs from any dashboard and send them to interested parties on a schedule.
The Starred dashboards section lets you customize the UI by saving dashboards you frequently use at the top of the menu. We will explore using dashboards more fully in Chapter 8.
Explore
Section titled “Explore”Explore is the way to get direct access to the data that is connected to the Grafana instance. This is the foundation of building custom dashboards and exploring data to understand the current state of the system. We will look at this briefly later in this chapter in the section titled Exploring telemetry from the demo application, and in a lot more detail in Chapters 4, 5, and 6.
Alerts & IRM
Section titled “Alerts & IRM”The Alerts & IRM section contains Grafana’s Alerting, OnCall, and Incident systems for IRM, as well as machine learning capabilities and the SLO service. These can help with identifying anomalies in the system (for more details on this, you can refer to Chapter 9):

Figure 3.8 – Alerts & IRM
Alerting, or Alertmanager, allows teams to manage rules for when an alert should be triggered. It also gives teams control over the method of notification used for the alert and whether there are any schedules for when to alert. Grafana Alerting is geared toward notifying an individual team of alerts in their system, and it has been battle-tested by many organizations.
OnCall and Incident form Grafana’s IRM toolkit. This gives organizations the ability to receive notifications from many monitoring systems and manage schedules and escalation chains, as well as giving high-level visibility of sent, acknowledged, resolved, and silenced alerts. The Incident section gives organizations the ability to start incidents. These follow predefined processes for involving the right people and communicating with stakeholders. Once the incident is initiated, Grafana can record key moments during the incident process ready for any post-incident processes. Both OnCall and Incident are aimed at organizations that need a central hub to manage the technical aspects of problem and incident management. Chapter 9 will explore these tools in greater detail and show you how to configure them.
Performance testing
Section titled “Performance testing”The Performance testing area is where the k6 performance testing tool is integrated with the Grafana UI, allowing teams to manage tests and projects. k6 allows your teams to use the same performance testing tools in the CI/CD pipeline as they use to test against production. k6 will be covered in Chapter 13.
Observability
Section titled “Observability”The Observability section brings together Kubernetes infrastructure and application monitoring, with synthetic tests used to simulate critical user journeys in your application alongside frontend real user monitoring (RUM) and profiles from Pyroscope. By combining these data sources, you gain an end-to-end view of the current performance of your products.
Connections
Section titled “Connections”The Connections section is an administrative area to set up and manage connections from Grafana to the 160+ data sources and infrastructure components that it can connect and show data from. Some examples of available connections are Elastisearch, Datadog, Splunk, AWS, Azure, cert-manager, GitHub, Ethereum, and Snowflake. The page to configure these connections is shown in the following figure:

Figure 3.9 – Connections screen
Administration
Section titled “Administration”The Administration panel allows for the management of many aspects of Grafana, from plugins and recorded queries to users, authentication, teams, and service accounts:

Figure 3.10 – Administration panel
Now that we’ve explored the Grafana Cloud Portal, let’s prepare your local environment to send data.
Installing the prerequisite tools
Section titled “Installing the prerequisite tools”Grafana is much more exciting with data! To build a realistic view of how Grafana works and can help your organization, we have chosen to install the OpenTelemetry demo application. This is a demonstration web store that sells telescopes and other observational equipment. We’ll take you through the installation process to get this running locally on your machine.
But first, there are a few prerequisites that your local environment has, and they depend on the operating system you use.
In this section, we will explain how to install the following:
- Tools based on your operating system:
- Windows Subsystem for Linux version 2 (WSL2)
- macOS Homebrew
- Windows Subsystem for Linux version 2 (WSL2)
- Docker or Podman
- A single-node Kubernetes cluster
- Helm
Installing WSL2
Section titled “Installing WSL2”WSL is a way of running a Linux filesystem and tools directly on Windows. This is used to give a standard set of commands and tools across operating systems. It is possible to run these systems outside of WSL, but the processes are much easier using WSL. Follow these steps to set up WSL2:
- Open a PowerShell terminal or Windows Command Prompt as an administrator.
- Run the following command to
This will install the Ubuntu distribution of Linux. You should see a message that Ubuntu is installing and then you will be prompted for a new UNIX username. If you see any other message, you may have a version of WSL installed already; please refer to the Microsoft website to address this.C:\Users\OwG> wsl --install
- Create a new user for your Ubuntu installation by entering a username and password. These do not need to match your Windows username and password.
- Upgrade packages by running the
It is recommended to install the Windows Terminal to use WSL. This can be downloaded from the Microsoft Store: https://learn.microsoft.com/en-us/windows/terminal/install.sudo apt update && sudo apt upgrade
More detailed instructions on how to complete this installation process and troubleshoot any issues that may arise can be found at https://learn.microsoft.com/en-us/windows/wsl/install.
Installing Homebrew
Section titled “Installing Homebrew”Homebrew is a package management tool for macOS. To install it on your system, follow these steps:
- Open a terminal window.
- Run the following command to
The script that runs will explain what it is doing and pause before continuing.$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Run the following command to install
wget(used later in the$ brew install wget
Detailed instructions on this installation can be found at https://brew.sh/.
Installing container orchestration tools
Section titled “Installing container orchestration tools”Docker and Podman are both container orchestration tools. Docker has been the de facto standard for about a decade. Podman is a newer tool. It was first released in 2018. The major functions of Docker are also offered in Podman, but support and information may be more difficult to find.
In 2021, Docker made licensing changes that became fully effective in January 2023. These licensing changes may impact readers using devices belonging to businesses. We will only provide instructions for Docker, but we will highlight the potential issues, so you are aware of them. The aim of providing a container orchestration tool is to run a single-node Kubernetes cluster on that tool.
Installing Docker Desktop
Section titled “Installing Docker Desktop”The following sections briefly describe how Docker Desktop can be installed on Windows, macOS, and Linux. Let’s look at the Windows installation process first.
Windows installation
Section titled “Windows installation”To install Docker Desktop on Windows, do the following:
- Go to https://docs.docker.com/desktop/install/windows-install/ and download the latest Docker installer
.``exefile. - Run the installation package. You will be prompted to enable WSL2. Select Yes.
- After installation, start Docker Desktop.
- Navigate to Settings | General. Select the Use WSL2 based engine checkbox.
- Select Apply & Restart.
- In your WSL terminal, validate the Docker installation by running the
$ docker --versionDocker version 20.10.24, build 297e128
macOS installation
Section titled “macOS installation”For the macOS installation of Docker Desktop, do the following:
- Go to https://docs.docker.com/desktop/install/mac-install/ and download the latest Docker installer for your Mac.
- Run the installation package.
- In your terminal, validate the Docker installation by running
$ docker --versionDocker version 20.10.24, build 297e128
Linux installation
Section titled “Linux installation”Linux users may consider using Podman Desktop as it has better native support for Linux environments. Installation instructions are available at https://podman-desktop.io/docs/Installation/linux-install.
However, if you do wish to use Docker, please follow the installation guide provided as the process will vary by distribution: https://docs.docker.com/desktop/install/linux-install/.
The full documentation can be found at https://docs.docker.com/desktop/.
With a base system that now supports containerization, let’s set up a single-node Kubernetes cluster. This will be used to easily and repeatably install the OpenTelemetry demo application.
Installing a single-node Kubernetes cluster
Section titled “Installing a single-node Kubernetes cluster”There are a few different tools to run local Kubernetes clusters, including Kubernetes in Docker (KinD), Minikube, and MicroK8s. However, we have chosen to use k3d due to the ease of installation across operating systems. Follow these steps:
- Install k3d using the
Full details can be found at https://k3d.io/stable/.$ wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
- Create a
$ k3d cluster create owg-otel-demo
- Validate the
$ kubectl get nodesNAME STATUS ROLES AGE VERSIONk3d-owg-otel-demo-server-0 Ready control-plane,master 13d v1.25.7+k3s1
With a Kubernetes cluster installed, we now need a way to install applications easily. OpenTelemetry provides Helm charts, which allow us to deploy applications to Kubernetes; we will install Helm to use these.
Installing Helm
Section titled “Installing Helm”Helm is a package manager for Kubernetes clusters. A lot of infrastructure-level components are provided as Helm charts for installation, and OpenTelemetry is no exception. To install Helm, follow these steps:
- Install Helm using the following command (details can be found https://helm.sh/docs/intro/install/
$ wget –q –O - https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- Validate the
$ helm versionversion.BuildInfo{Version:"v3.11.3", GitCommit:"323249351482b3bbfc9f5004f65d400aa70f9ae7", GitTreeState:"clean", GoVersion:"go1.20.3"}
With our local system ready to start running applications, we can now install the demo application provided by OpenTelemetry.
Installing the OpenTelemetry Demo application
Section titled “Installing the OpenTelemetry Demo application”As we need to send data from our local machine to our Grafana Cloud instance, we need to provide some credentials and tell our local machine where to send data. Before we install the demo application, we need to set up access tokens so we can send data to our Grafana Cloud stack.
Setting up access credentials
Section titled “Setting up access credentials”Access tokens allow the Open Telemetry application to send data securely to your Grafana Cloud stack. To set up an access token, we need to do the following:
- In the Grafana Cloud Portal, select Access Policies in the Security section.
- Click Create access policy.
- Choose a name and display name, and set Realm to All Stacks.
- Set the Write scope for metrics, logs, and traces and click Create.
- On the new access policy, click Add token.
- Give the token a name and set the expiration date. Click Create.
- Finally, copy the token and save it securely.
Now that we’ve created our token, let’s download the GitHub repository for this book and set it up.
Downloading the repository and adding credentials and endpoints
Section titled “Downloading the repository and adding credentials and endpoints”The Git repository contains configuration files for each of the chapters that will use live data. Downloading the repository is simple. Go to the Git repository: https://github.com/PacktPublishing/Observability-with-Grafana. Click on the green Code button and follow the instructions to clone the repository. Once downloaded, the repository should look like this:

Figure 3.11 – Observability with Grafana repo
To set up the demo application, we need to add the token we saved in the previous section and the correct endpoints in the OTEL-Creds.yaml file. The information you will need is the following:
- Password: This is the token you saved earlier and is shared by each telemetry type
- Username: This is specific to each telemetry type
- Endpoint: This is also specific to each telemetry type
Let’s take Loki as an example of how to get this information. In the Grafana Cloud Portal, do the following to get the correct information:
- Click on the Send Logs button in the Loki box. At the top of the page is an information box that looks like this:

Figure 3.12 – Grafana Data Source settings
- The User field is used as the username.
- The URL field is used as the endpoint. This needs modifying:
- For logs, add
/loki/api/v1/pushto the end of the URL- For metrics, add
/api/prom/pushto the end of the URL - For traces, remove
https://and add:443to the end of the URL
- For metrics, add
- For logs, add
- Add this information into the relevant fields in the
OTEL-Creds.yamlfile.
With Loki completed, we can follow the same process for Prometheus (click Send Metrics) and Tempo (click Send Traces).
These instructions are repeated and expanded on in the README.md file in the repository. With the credentials saved, we are now ready to deploy OpenTelemetry.
Installing the OpenTelemetry Collector
Section titled “Installing the OpenTelemetry Collector”With the credentials file updated, we can now install the Helm chart for the OpenTelemetry Collector. This is the component that will collect and transmit the data produced by the demo application. To proceed with the installation, perform the following steps:
- Add the
$ helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
- Install the collector
$ helm install --version '0.73.1' --values chapter3/OTEL-Collector.yaml --values OTEL-Creds.yaml owg open-telemetry/opentelemetry-collectorNAME: owg-otel-collectorLAST DEPLOYED: Sun May 14 13:53:16 2023NAMESPACE: defaultSTATUS: deployedREVISION: 1…
- Validate that the installation
$ kubectl get podsNAME READY STATUS RESTARTS AGEowg-otel-collector-opentelemetry-collector-6b8fdddc9d-4tsj5 1/1 Running 0 2s
We are now ready to install the OpenTelemetry demo application.
Installing the OpenTelemetry demo application
Section titled “Installing the OpenTelemetry demo application”The OpenTelemetry demo application is an example web store that sells telescopes and other tools to observe the universe. To install this demo application, follow these steps:
- Install the demo application
$ helm install --version '0.26.0' --values owg-demo open-telemetry/opentelemetry-demoNAME: owg-otel-demoLAST DEPLOYED: Mon May 15 21:58:37 2023NAMESPACE: defaultSTATUS: deployedREVISION: 1…
- Validate that the installation was successful. This process may take a few minutes on the
You should see about 19 Pods running.$ kubectl get pods
- Open a port for
frontendproxy$ kubectl port-forward svc/owg-demo-frontendproxy 8080:8080 & - Open a port for
$ kubectl port-forward svc/owg-opentelemetry-collector 4318:4318 &
- Check you can access the OpenTelemetry demo application on http://localhost:8080:

Figure 3.13 – OpenTelemetry demo application
- Explore the OpenTelemetry demo application to generate some data. Take some time to add items to your cart and purchase them. While a load generator is part of the installation, it is worth getting familiar with the application as it will help put the telemetry generated in context.
Now that you have an application that produces data, let’s start exploring that data.
Exploring telemetry from the demo application
Section titled “Exploring telemetry from the demo application”Assuming the installation was successful, you will have data flowing into your Grafana instance. To view these, head to your Grafana instance, either from your team URL or by clicking Launch in the Cloud Portal.
On the front page, you should see information detailing your current or billable usage of logs, metrics, and traces. If everything is correct, these should all be greater than 0. It may take a few minutes for this to show up completely, sometimes up to an hour:

Figure 3.14 – Grafana Cloud usage
Important note
If you don’t see usage for metrics, logs, and traces, you might need to troubleshoot. We have included some tips at the end of this chapter.
Click on the menu and select Explore. This will take you to the page to run queries on the telemetry from the demo application. The highest-level concept in Grafana is a data source. These are selectable just below the main menu. Each data source is a connection from the Grafana instance to either a component in the Grafana Stack or a connection to another tool. Each data source is self-contained. The data source menu can be seen in the following figure:

Figure 3.15 – Data source menu
You will see that there are data sources for logs, prom (Prometheus metrics), and traces. There are other data sources, but for this chapter, we will only concentrate on these three, as they are the data sources related to the Grafana Stack we have provisioned.
These data sources relate to our Loki, Mimir, and Tempo components, used to collect logs, metrics, and traces, respectively. We’ll discuss these next.
Logs in Loki
Section titled “Logs in Loki”Loki stores the log data produced by the demo application. Let’s have a quick look at the interface for a Loki data source and see some of the log data the demo application is producing.
Select the grafanacloud-<team name>-logs data source. In Label filters, add exporter = OTLP and click Run query. You should now see a screen like this:

Fig 3.16 – Reviewing logs
The upper area of the screen is where you enter and modify your query. In the middle of the screen, you will see the volume of logs returned by your search over time. This can provide a lot of contextual information at a glance. The lower part of the screen displays the results of your query:

Figure 3.17 Query panel details
Let’s break the preceding screenshot down into its components:
- You can select the time range and add the query to various tools by clicking on Add.
- Using the buttons at the bottom of this section, you can use Add query to produce a more complex analysis of the data. Query history lets you review your query history. Query inspector helps to understand how your query is performing.
- The Builder or Code selector allows you to switch between the UI-focused query builder you see by default and a query language entry box, which is useful for directly entering queries.
- The Kick start your query button will give you some starter queries and the Label browser button will let you explore the labels currently available in your collected log data.
- Finally, the Explain query slider will give you a detailed explanation of each step of the query you currently have.
Let’s take a look at the components in the query result panel:

Figure 3.18 – Query result panel details
These components can be used as follows:
- You can customize the display of this data to show the timestamp, highlight any unique labels, wrap lines, or prettify JSON.
- You can also apply deduplication.
- You can choose to view the oldest or newest log events first.
- Finally, you can download the data as
.txtor.json.
We will look at these features in more depth in Chapter 4 and introduce the LogQL query language.
Now that you have familiarized yourself with the query panels for logs in a Loki data source, let’s see how querying metrics from a Mimir data source is very similar.
Metrics in Prometheus/Mimir
Section titled “Metrics in Prometheus/Mimir”Grafana uses similar repeating blocks for querying data. In this section, we will explore how to query metrics.
Select the grafanacloud-<team name>-prom data source. In the Metric dropdown, select kafka_consumer_commit_rate and leave Label filters blank. Click on Run query and you should see a screen like this:

Figure 3.19 – Kafka consumer commit rate
Similar to Loki, we have a query section at the top, although the structure is slightly different. The major difference is the Options section, which controls how the data is presented. Legend manages the graph’s legend display. The Format option allows you to select between a Time series representation (the graph shown in the preceding screenshot); a Table representation, showing each value of each time series; and a Heatmap representation. The Type selector allows you to select either a range of time, the latest instant of each time series, or both. The Exemplars slider will show trace data that is linked to each metric.
The bottom section shows the data, with options to display it in different ways.
To see how Grafana represents multiple plots, from the Metric dropdown, select process_runtime_jvm_cpu_utilization_ratio and click Run query. You should see a chart like this:

Figure 3.20 – JVM CPU utilization
Each of the plotted lines in the chart in the preceding screenshot represents the CPU utilization of a different service running in the demo application. We will look at these features in more depth in Chapter 5 and introduce the PromQL query language.
A Tempo trace data source is very similar to a Loki log data source and a Mimir metric data source. Let’s look at this now.
Traces in Tempo
Section titled “Traces in Tempo”Traces use a little bit more querying, as we have to find and select an individual trace, and then show the spans in the trace in detail.
Select the grafanacloud-<team name>-traces data source. For Query type, choose Search, for Service Name, select checkoutservice, and click Run query. You should see a screen like this:

Figure 3.21 – Selecting a trace
Click on one of the Trace ID links and you will see a screen like this:

Figure 3.22 – Trace view
This view shows the split view that Grafana offers. This can be accessed from any data source and can provide the ability to use linked data points to move between logs, metrics, and traces to see the same point in time or event in each of the telemetry types. If you select the bar between the panels, indicated by the number 1 in the preceding screenshot, you can make the trace view bigger by clicking and dragging.
Looking through the trace, each line represents a span with information on which service was involved alongside specific information from that service. For example, checkoutservice will show you the count of items in the cart and the shipping amount. The bars with each span show the total time that span took and are stacked to represent the relative start and end times of the span. You might see that productcatalogueservice takes up a significant portion of the time in the transaction in Figure 3*.21*.
Adding your own applications
Section titled “Adding your own applications”It is possible to add your own application to this demo installation. The OpenTelemetry Collector has been deployed with receivers available for OTLP-formatted data on port 4317 for gRPC data and 4318 for HTTP(s) data. To deploy your application, it will need to be packaged as a container and then just follow a standard deployment mechanism for a Kubernetes deployment. Please do note that k3d is opinionated and by default uses Flannel and Traefik for networking and ingress, respectively.
Now that we’ve understood this demo application, let’s look at some troubleshooting tips that will help you if you’re facing any issues while setting it up or using it.
Troubleshooting your OpenTelemetry Demo installation
Section titled “Troubleshooting your OpenTelemetry Demo installation”There are various things that could go wrong while using this application, so this section is not necessarily exhaustive. We will assume that all the prerequisite tools were installed correctly.
Let’s first take a look at the correct formatting of Grafana credentials.
Checking Grafana credentials
Section titled “Checking Grafana credentials”If the OpenTelemetry Collector is giving authentication errors, or you are not receiving data from it, it is likely that the credentials are not formatted correctly. These details are entered into the OTEL-Creds.yaml file from this book’s Git repository.
The Grafana credentials should be formed like this:
- Username: Number, typically six digits.
- Password: API token, which is a long string of letters and numbers. When troubleshooting the token there are some important considerations:
- The same token can be shared by all the exporters.
- The Access policy associated with the API token needs to be able to write logs, metrics and traces. This can be checked in the Grafana Cloud portal.
- The same token can be shared by all the exporters.
- Endpoint: The URL that the OpenTelemetry Collector will push data to. These are the endpoints that are provided by the Grafana Cloud installation you set up in an earlier section, Introducing Grafana Cloud.
The following are sample endpoints. Yours will be different, but they will be similarly formed:
loki:https://logs-prod-006.grafana.net/loki/api/v1/pushprometheusremotewrite:https://prometheus-prod-13-prod-us-east-0.grafana.net/api/prom/pushotlp(tempo):tempo-prod-04-prod-us-east-0.grafana.net:443
Important note
The OTLP endpoint for Tempo is different from the others.
If you notice that you have made a mistake, you will need to use helm upgrade to deploy the changes you make to the OTEL-Creds.yaml file:
$ helm upgrade --version '0.73.1' --values chapter3/OTEL-Collector.yaml --values OTEL-Creds.yaml owg open-telemetry/opentelemetry-collectorYou can also use helm uninstall and then use the original instructions to reinstall.
The most common problem is with the access credentials, but sometimes you will need to look at the collector logs to understand what is happening. Let’s see how to do this now.
Reading logs from the OpenTelemetry Collector
Section titled “Reading logs from the OpenTelemetry Collector”The next place to investigate is the logs from the OpenTelemetry Collector.
Kubernetes allows you to directly read the logs from a Pod. To do this, you need the full Pod name, which you can get using the following command:
$ kubectl get pods --selector=app.kubernetes.io/instance=owgNAME READY STATUS RESTARTS AGEowg-opentelemetry-collector-567579558c-std2x 1/1 Running 0 6h26mIn this case, the full Pod name is owg-opentelemetry-collector-567579558c-std2x.
To read the logs, run the following command:
$ kubectl logs owg-opentelemetry-collector-567579558c-std2xLook for any warning or error-level events, which should give an indication of the issue that is occurring.
Sometimes, the default logging does not give enough information. Let’s see how we can increase the logging level.
Debugging logs from the OpenTelemetry Collector
Section titled “Debugging logs from the OpenTelemetry Collector”If the standard logs are not enough to resolve the problem, the OpenTelemetry Collector allows you to switch on debug logging. This is typically verbose, but it is very helpful in understanding the problem.
At the end of OTEL-Creds.yaml, we have included a section to manage the debug exporter. The verbosity can be set to detailed, normal, or basic.
For most use cases, switching to normal will offer enough information, but if this does not help you to address the problem, switch to detailed. Once this option is changed, you will need to redeploy the Helm chart:
$ helm upgrade owg open-telemetry/opentelemetry-collector -f OTEL-Collector.yamlThis will restart the Pod, so you will need to get the new Pod ID. With that new ID, you can look at the logs; as we saw in the previous section, you should have a lot more detail.
Summary
Section titled “Summary”In this chapter, we have seen how to set up a Grafana Cloud account and the main screens available in the portal. We set up our local machine to run the OpenTelemetry demo application and installed the components for this. Finally, we looked a the data produced by the demo application in our Grafana Cloud account. This chapter has helped you set up an application that will produce data that is visible in your Grafana Cloud instance, so you can explore the more detailed concepts introduced later with real examples.
In the next chapter, we will begin to look in depth at logs and Loki, explaining how best to categorize data to give you great insights.