• Stars
    star
    185
  • Rank 200,878 (Top 5 %)
  • Language Jsonnet
  • Created about 3 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Observability Demo App

The New Stack (TNS) observability app

This readme has the following sections:

Overview

The New Stack (TNS) is a simple three-tier demo application, fully instrumented with the 3 pillars of observability: metrics, logs, and traces. It offers an insight on what a modern observability stack looks like and experience what it's like to pivot among different types of observability data.

TNS workflow

The TNS app is an example three-tier web app built by Weaveworks. It consists of a data layer, application logic layer, and load-balancing layer. To learn more about it, see How To Detect, Map and Monitor Docker Containers with Weave Scope from Weaveworks.

The instrumentation for the TNS app is as follows:

  • Metrics: Each tier of the TNS app exposes metrics on /metrics endpoints, which are scraped by the Grafana Agent. Additionally, these metrics are tagged with exemplar information. The Grafana Agent then writes these metrics to Mimir for storage.

  • Logs: Each tier of the TNS app writes logs to standard output or standard error. It is captured by Kubernetes, which are then collected by the Grafana Agent. Finally, the Agent forwards them to Loki for storage.

  • Traces: Each tier of the TNS app sends traces in Jaeger format to the Grafana Agent, which then converts them to OTel format and forwards them to Tempo for storage.

Visualization: A Grafana instance configured to talk to the Mimir, Loki, and Tempo instances makes it possible to query and visualize the metrics, logs, and traces data.

Prerequisites

If you are running the full metrics, logs and traces stack locally, install and configure all of the following software applications.

If you wish to only deploy the TNS app to an existing K8s cluster using the app-only option, install and configure kubectl, tanka, and jsonnet-bundler.

Go

Since much of the program is written in Go, you should have have Go installed on your local machine. Click [here] (https://go.dev/doc/install) for installation instructions.

Docker

Make sure you have Docker installed and verify it is running with docker ps. No errors means it is running. For Docker download and installation instructions, click here.

If using Linux and you see an error similar to permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock then make sure you are in the docker group. This will ensure that you are able to run Docker without using the sudo command.

$ sudo usermod -aG docker <username>

Logout and then login again for the changes to take effect.

K3D

To run the TNS demo, you need a Kubernetes cluster. The cluster creation script uses k3d which runs as a single node cluster inside Docker. The specific version to use depends on your operating system:

Note: Ensure that your Docker daemon has a minimum of 2.5 GB of total memory available for all pods in this deployment to be scheduled.

You can also run the TNS demo without Kubernetes. Click here for more information.

kubectl

The TNS demo uses kubectl to interact with the Kubernetes clusters. Click here for kubectl installation instructions.

Tanka

Tanka uses the Jsonnet language to interact with Kubernetes, via the kubectl tool. Click here for installation instructions.

Reviewing the Tanka code

When you install the TNS demo application, it will create a tanka directory in your TNS checkout. This directory contains all of the Jsonnet resources used to install this demo. To find out more about Tanka, see https://tanka.dev.

Jsonnet-bundler

The Jsonnet bundler downloads Jsonnet dependencies. Click here for installation instructions.

After the installation type jb in the terminal to make sure it is added to the system path and working.

Install TNS demo (running MLT stack locally)

These instructions assume that you are using a local k3d. If you plan to use a Kubernetes cluster other than a local k3d one, you will need to modify these instructions for your setup.

  1. Clone the TNS repository.

    $ git clone https://github.com/grafana/tns
    $ cd tns
  2. Install K3D cluster.

    $ ./create-k3d-cluster
    $ export KUBECONFIG=$(k3d kubeconfig write tns)
  3. Install TNS demo application:

    $ ./install
  4. Confirm yes when prompted. You will be prompted five times during the installation.

    Wait for the installation to finish. It can take over ten minutes for everything to download and then start up.

  5. Verify the status of your cluster by running this command.

    $ kubectl get pods -A

    If all the pods are listed as either running or completed, your cluster is ready for use.

  6. Access TNS using the URL http://localhost:8080/.

Note: If you need to re-do this process to get everything running, you can run k3d cluster delete tns to delete the cluster, then run ./create-k3d-cluster and re-start the process.

Install TNS demo app into an existing K8s cluster (app-only option)

If you already have a K8s cluster and cloud metrics, logs, and traces services available to you, use the app-only option to deploy only the instrumented TNS app to a Kubernetes cluster.

  1. Get Kubernetes context

    $ kubectl config get-contexts

    Note down the context you'd like to use to deploy the app.

  2. Deploy the app

    $ ./install CONTEXT_YOU_NOTED app-only
  3. Confirm yes when prompted.

  4. Verify the status of your cluster by running this command.

    $ kubectl get pods -n tns-cloud

    If all the pods are listed as either running, your app is ready for use.

Install TNS demo app connected to Grafana Cloud (grafana-cloud option)

Note: this requires an existing K8S cluster.

  1. Get Kubernetes context

    $ kubectl config get-contexts

    Note down the context you'd like to use to deploy the app.

  2. Deploy the app

    $ ./install CONTEXT_YOU_NOTED grafana-cloud
  3. You will need to provide your organization name (slug), API Token, and stack.

    • To create an Access Policy and Token, go to https://grafana.com/orgs/<your_slug>/access-policies
    • Create new access policy with the minimum privileges:
      • Realms: the stack you wish to send TNS data to
      • Scopes: stacks:read, logs:write, metrics:write, profiles:write
    • Create new access token for this policy
  4. Confirm yes when prompted about applying changes to your cluster

  5. Verify the status of your cluster by running this command.

    $ kubectl get pods -n tns-cloud

    If all the pods are listed as either running, your app is ready for use.

After a few minutes, you will see metrics arriving in your Grafana instance. At this point, you can also enable the Kubernetes Integration - the agent is already configured for you!

Explore metrics to logs to traces

The following instructions will help you go from metrics to logs to traces.

  1. Open the TNS dashboard.
  2. Zoom in on a section of a panel with failed requests.
  3. From the panel drop-down, click Explore.
  4. In the Explore view, go to the data source drop-down and select Loki.
  5. Click to expand a logline with a TraceID field.
  6. Click the Tempo button next to the TraceID field to view the trace.

Explore metrics to traces to logs

The following instructions will help you go from metrics to traces to logs.

  1. In Grafana, go to the Explore view.
  2. From the data source drop-down, select Mimir.
  3. Run the following query: histogram_quantile(.99, sum(rate(tns_request_duration_seconds_bucket{}[1m])) by (le))
  4. Click on a data point to see the exemplar data as a tooltip. (If no data points appear, make sure exemplars are enabled in the query options.)
  5. Click on the log icon on a span line to view the log details.

Explore logs to traces with LogQL V2

  1. In Grafana, go to the Explore view.
  2. From the data source drop-down, select Loki.
  3. Run the following query: {job="tns/app"} | logfmt | level="info" | status>=500 and status <=599 and duration > 50ms
  4. Click to expand a logline with a TraceID field.
  5. Click the Tempo button next to the TraceID field to view the trace.

Disable TNS cluster

To disable your cluster, run this command:

$ k3d cluster stop tns

To re-enable the cluster, run this command:

$ k3d cluster start tns

Remove TNS cluster

To remove your cluster, run this command:

$ k3d cluster delete tns
$ rm -rf tanka

Contributing guidelines

Modify TNS application:

  • Run make to compile the code and tag new images in your local Docker image registry, after you have modified the source code of the TNS demo application,
  • Instruct k3d to pull the new images on a pod restart (and not use the image from it's local cache): k3d image import -c tns grafana/tns-app && k3d image import -c tns grafana/tns-db && k3d image import -c tns grafana/tns-loadgen.
  • Kill relevant pod(s) by running the following command: kubectl delete pod app-69db48747b-s6qq6 --namespace=tns.

Update Grafana dashboards and kubernetes infrastructure:

  • Update the manifests by running the following tanka command: tk apply --force environments/<ENV>/main.jsonnet.
  • Update Grafana, for example, when changing dashboards by running the following tanka command: tk apply --force environments/default/main.jsonnet.

Using TNS for Grafana Development

The setup in this repo can help provide you with everything you need to use TNS' setup to work with local Grafana development. For more information, see the README in production/docker-compose

More Repositories

1

grafana

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
TypeScript
60,280
star
2

k6

A modern load testing tool, using Go and JavaScript - https://k6.io
Go
22,905
star
3

loki

Like Prometheus, but for logs.
Go
22,069
star
4

pyroscope

Continuous Profiling Platform. Debug performance issues down to a single line of code
C
9,361
star
5

mimir

Grafana Mimir provides horizontally scalable, highly available, multi-tenant, long-term storage for Prometheus.
Go
3,634
star
6

tempo

Grafana Tempo is a high volume, minimal dependency distributed tracing backend.
Go
3,561
star
7

oncall

Developer-friendly incident response with brilliant Slack integration
Python
3,223
star
8

tanka

Flexible, reusable and concise configuration for Kubernetes
Go
2,235
star
9

phlare

🔥 horizontally-scalable, highly-available, multi-tenant continuous profiling aggregation system
Go
2,059
star
10

grafana-zabbix

Zabbix plugin for Grafana dashboard
TypeScript
2,020
star
11

agent

Vendor-neutral programmable observability pipelines.
Go
1,544
star
12

helm-charts

Smarty
1,494
star
13

grafonnet-lib

Jsonnet library for generating Grafana dashboard files.
Jsonnet
1,079
star
14

beyla

eBPF-based autoinstrumentation of HTTP and HTTPS services
C
1,032
star
15

grafana-operator

An operator for Grafana that installs and manages Grafana instances, Dashboards and Datasources through Kubernetes/OpenShift CRs
Go
756
star
16

alloy

OpenTelemetry Collector distribution with programmable pipelines
Go
711
star
17

grafana-docker

Grafana docker container
Shell
638
star
18

metrictank

metrics2.0 based, multi-tenant timeseries store for Graphite and friends.
Go
623
star
19

faro-web-sdk

The Grafana Faro Web SDK, part of the Grafana Faro project, is a highly configurable web SDK for real user monitoring (RUM) that instruments browser frontend applications to capture observability signals. Frontend telemetry can then be correlated with backend and infrastructure data for full-stack observability.
TypeScript
623
star
20

grafana-infinity-datasource

CSV, JSON, GraphQL, XML and HTML datasource for grafana.
TypeScript
591
star
21

jsonnet-libs

Grafana Labs' Jsonnet libraries
Jsonnet
516
star
22

k6-operator

An operator for running distributed k6 tests.
Go
506
star
23

simple-json-datasource

Datasource that sends generic http requests to give url
JavaScript
502
star
24

awesome-k6

A curated list of awesome tools, content and projects using k6
493
star
25

carbon-relay-ng

Fast carbon relay+aggregator with admin interfaces for making changes online - production ready
Go
455
star
26

grizzly

A utility for managing Jsonnet dashboards against the Grafana API
Go
424
star
27

terraform-provider-grafana

Terraform Grafana provider
Go
391
star
28

grafana-image-renderer

A Grafana backend plugin that handles rendering of panels & dashboards to PNGs using headless browser (Chromium/Chrome)
TypeScript
335
star
29

dskit

Distributed systems kit
Go
316
star
30

grafana-kiosk

Kiosk Utility for Grafana
Go
314
star
31

xk6-browser

k6 extension that adds support for browser automation and end-to-end web testing via the Chrome Devtools Protocol
Go
310
star
32

worldmap-panel

Worldmap panel plugin for Grafana 3.0 that can be overlaid with circles for data points.
JavaScript
301
star
33

postman-to-k6

Converts Postman collections to k6 script code
JavaScript
286
star
34

xk6-dashboard

A k6 extension that makes k6 metrics available on a web-based dashboard.
HTML
278
star
35

grafana-json-datasource

A data source plugin for loading JSON APIs into Grafana.
TypeScript
261
star
36

k6-learn

JavaScript
255
star
37

k6-template-typescript

Template to use TypeScript with k6
TypeScript
250
star
38

grafonnet

Jsonnet library for generating Grafana dashboards.
Jsonnet
229
star
39

dashboard-linter

A tool to lint Grafana dashboards
Go
187
star
40

thema

A CUE-based framework for portable, evolvable schema
Go
185
star
41

intro-to-mltp

Introduction to Metrics, Logs, Traces and Profiles session companion code.
JavaScript
181
star
42

strava-datasource

Strava datasource for Grafana dashboard
TypeScript
171
star
43

xk6

Build k6 with extensions
Go
169
star
44

github-datasource

Grafana data source plugin using the Github API to retrieve and visualize Github data.
Go
169
star
45

grafana-plugin-sdk-go

A Go SDK for building backend plugins for Grafana
Go
165
star
46

jsonnet-language-server

A Language Server Protocol (LSP) server for Jsonnet (https://jsonnet.org)
Go
154
star
47

grafana-plugin-examples

Shell
152
star
48

django-saml2-auth

Django SAML2 Authentication Made Easy. Easily integrate with SAML2 SSO identity providers like Okta, Azure AD and others.
Python
151
star
49

cortex-tools

If you're using this tool with Grafana Mimir, please switch to "mimirtool" instead: https://github.com/grafana/mimir
Go
150
star
50

piechart-panel

Pie Chart Panel Plugin
JavaScript
150
star
51

grafana-plugin-repository

The plugin repository for plugins that are published on grafana.com.
JavaScript
147
star
52

mqtt-datasource

MQTT Datasource for Grafana allows streaming data from any MQTT broker running either locally or remotely.
Go
143
star
53

xk6-output-prometheus-remote

k6 extension to output real-time test metrics using Prometheus Remote Write.
Go
139
star
54

scribe

A tool for building elaborate CI pipelines using a familiar programming language
Go
124
star
55

kubernetes-diff-logger

Logs updates to Kubernetes Objects for storing and querying with Loki
Go
122
star
56

pyroscope-rs

Pyroscope Profiler for Rust. Profile your Rust applications.
Rust
119
star
57

synthetic-monitoring-agent

Synthetic Monitoring Agent
Go
118
star
58

har-to-k6

JSON config representation of K6 script
JavaScript
114
star
59

scenes

Build Grafana dashboards directly in your Grafana app plugins.
TypeScript
114
star
60

faro

Grafana Faro is a project for frontend application observability. It includes a highly configurable web SDK that instruments browser frontend applications to capture observability signals.
113
star
61

google-sheets-datasource

Load Google Sheets in grafana
Go
112
star
62

tutorials

A series of tutorials for helping you make the most out of Grafana.
Makefile
109
star
63

synthetic-monitoring-app

Synthetic Monitoring frontend application
TypeScript
107
star
64

grafana-api-golang-client

Grafana HTTP API Client for Go
Go
105
star
65

k6-action

k6 is now available as a GitHub Action
JavaScript
101
star
66

clickhouse-datasource

Grafana Plugin for ClickHouse
TypeScript
101
star
67

k8s-monitoring-helm

Shell
96
star
68

cuetsy

Experimental CUE->TypeScript exporter
Go
96
star
69

rollout-operator

Kubernetes Rollout Operator
Go
96
star
70

azure-monitor-datasource

Grafana data source for Azure Monitor/Application Insights (deprecated - now included in core Grafana)
TypeScript
92
star
71

dashboard-spec

Go
91
star
72

clock-panel

Clock Panel Plugin for Grafana
TypeScript
88
star
73

grafana-polystat-panel

D3-Based hexagon layout multi-stat panel
TypeScript
86
star
74

docker-otel-lgtm

Dockerfile
82
star
75

k6-docs

The k6 documentation website.
JavaScript
80
star
76

xk6-disruptor

Extension for injecting faults into k6 tests
Go
80
star
77

k6-template-es6

Template using Webpack and Babel to enable ES6 features in k6 tests
JavaScript
77
star
78

cortex-jsonnet

Deprecated: see https://github.com/grafana/mimir/tree/main/operations/mimir instead
Jsonnet
74
star
79

doom-datasource

Hackathon project
C
71
star
80

tutorial-environment

Environment for tutorial excercises
Go
70
star
81

pyroscope-go

This is the golang client integration for Pyroscope
Go
69
star
82

grafana-ansible-collection

grafana.grafana Ansible collection provides modules and roles for managing various resources on Grafana Cloud and roles to manage and deploy Grafana Agent and Grafana
Python
69
star
83

database-migrator

Code to export grafana.db (sqlite) to MySQL-compatible SQL file, to assist in migration of Grafana data to MySQL-compatible DB.
Shell
67
star
84

grafana-csv-datasource

A data source for loading CSV data into Grafana.
TypeScript
67
star
85

mimir-proxies

Proxies to help you ingest your metrics into Grafana Mimir.
Go
65
star
86

pyroscope-java

pyroscope java integration
Java
65
star
87

otel-profiling-go

Open Telemetry integration for Grafana Pyroscope and tracing solutions such as Grafana Tempo, Honeycomb, or Jaeger
Go
65
star
88

memo

easily save grafana annotations from slack mentions and the cli
Go
65
star
89

JPProf

Go Pprof but for Java runtime.
Java
65
star
90

grafana-starter-panel

A starter for Grafana panel plugins
TypeScript
65
star
91

xk6-sql

k6 extension to load test RDBMSs (PostgreSQL, MySQL, MS SQL and SQLite3)
Go
64
star
92

vscode-jsonnet

Full code support (formatting, highlighting, navigation, etc) for Jsonnet
JavaScript
64
star
93

jmeter-to-k6

Converts JMeter .jmx files to k6 JS code
JavaScript
63
star
94

xk6-distributed-tracing

A k6 extension for distributed tracing.
Go
62
star
95

github-to-es

GitHub Analytics With Elasticsearch And Grafana
JavaScript
54
star
96

opcua-datasource

An OPC UA datasource for reading from OPC UA servers (DA/HDA/AE) into Grafana directly
CSS
54
star
97

grafana-plugin-sdk-rust

Grafana Plugin SDK for Rust
Rust
53
star
98

xk6-kubernetes

Client extension for interacting with Kubernetes clusters from your k6 tests.
Go
52
star
99

regexp

Faster version of the Go regexp package
Go
51
star
100

influxdb-flux-datasource

Grafana datasource plugin for Flux (InfluxDB)
Go
51
star