• Stars
    star
    552
  • Rank 80,595 (Top 2 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created about 2 years ago
  • Updated 9 months ago

Reviews

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

Repository Details

PromLens – The query builder, analyzer, and explainer for PromQL

PromLens

PromLens is a web-based PromQL query builder, analyzer, and visualizer.

PromLens was initially created as a commercial software by PromLabs and then donated to the open-source Prometheus project by PromLabs and Chronosphere.

Reporting issues

Please file issues on the GitHub issue tracker.

Installing PromLens

There are multiple ways of installing PromLens:

Using pre-built release binaries

You can find pre-built release binaries for PromLens on the GitHub releases page.

Using Docker

Docker images are available on Docker Hub and Quay.

As a minimal example, you should be able to run PromLens like this:

docker run -p 8080:8080 prom/promlens

Building from source

To build PromLens from source, you need:

  • Go version 1.17 or greater.
  • NodeJS version 16 or greater.
    • Note: With NodeJS v17+ you may experience an error:0308010C:digital envelope routines::unsupported error. This can be worked around by either exporting the following environment variable NODE_OPTIONS=--openssl-legacy-provider (please be aware of security considerations) or downgrading to NodeJS v16 (source).
  • npm version 7 or greater.

Note: This is a non-exhaustive list of dependancies, as it is assumed some standard Unix tools are available on your system. Please review build error messages for more information on missing tools.

Start by cloning the repository:

git clone https://github.com/prometheus/promlens.git
cd promlens

Build PromLens:

make build

This builds the React-based web UI and compiles it into a Go binary that serves it.

Now you can run PromLens like this:

./promlens

Running PromLens

The following documents how to run PromLens with various options and features.

Example deployment

Let's start with a minimal and a more elaborate example first.

To run PromLens without any advanced features (link sharing, Grafana integration, etc.) enabled:

./promlens

This starts PromLens on http://localhost:8080/ (you can override this using the --web.listen-address flag).

To run PromLens with link sharing and Grafana integration enabled, using SQLite for link sharing (note that you will need to provide the $GRAFANA_URL and $GRAFANA_API_KEY environment variables for this to work):

./promlens \
  --shared-links.sql.driver=sqlite \
  --shared-links.sql.dsn=/tmp/promlens-links.db \
  --grafana.url=$GRAFANA_URL \
  --grafana.api-token=$GRAFANA_API_TOKEN

Command-line flags

To see all available command-line flags, run:

./promlens --help

For boolean flags that default to true, you can set them to false by specifying --no-<flag-name>, e.g. --no-shared-links.sql.create-tables.

Enabling link sharing

Link sharing allows persisting the state of an entire PromLens query page and sharing it with others.

By default, the link sharing backend is disabled. You can enable link sharing either via Google Cloud Storage, MySQL, or SQLite:

Google Cloud Storage

To use Google Cloud Storage (GCS) for link sharing, set the --shared-links.gcs.bucket=<bucket name> flag and set the GOOGLE_APPLICATION_CREDENTIALS environment variable to point to a JSON file containing your service account credentials (needs to have permission to create, delete, and view objects in the provided bucket).

SQLite

To save shared links to a local SQLite database, set the --shared-links.sql.driver=sqlite and --shared-links.sql.dsn=<database filename> flags.

MySQL

To save shared links in a MySQL database, set the --shared-links.sql.driver=mysql and --shared-links.sql.dsn=<data source name> flag (see https://github.com/go-sql-driver/mysql#dsn-data-source-name for MySQL DSN specifications).

By default, PromLens will try to auto-create the necessary tables in your MySQL database. This requires the PromLens database user to have CREATE permissions. To turn off automatic table creation for MySQL, set the --no-shared-links.sql.create-tables flag. If you want to create tables manually, run the following against your PromLens MySQL database:

CREATE TABLE IF NOT EXISTS link (
  id INT AUTO_INCREMENT PRIMARY KEY,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  short_name VARCHAR(11) UNIQUE,
  page_state TEXT
);

CREATE TABLE IF NOT EXISTS view(
  id INT AUTO_INCREMENT PRIMARY KEY,
  link_id INTEGER,
  viewed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY(link_id) REFERENCES link(id)
);

Postgres

To save shared links in a Postgres database, set the --shared-links.sql.driver=postgres and --shared-links.sql.dsn=<data source name> flag (see https://pkg.go.dev/github.com/lib/pq#hdr-Connection_String_Parameters for Postgres DSN specifications).

By default, PromLens will try to auto-create the necessary tables in your Postgres database. This requires the PromLens database user to have CREATE permissions. To turn off automatic table creation for Postgres, set the --no-shared-links.sql.create-tables flag. If you want to create tables manually, run the following against your PromLens Postgres database:

CREATE TABLE IF NOT EXISTS link (
  id SERIAL PRIMARY KEY,
  created_at timestamptz DEFAULT now(),
  short_name VARCHAR(11) UNIQUE,
  page_state TEXT
);

CREATE TABLE IF NOT EXISTS view(
  id SERIAL PRIMARY KEY,
  link_id INTEGER,
  viewed_at timestamptz DEFAULT now(),
  FOREIGN KEY(link_id) REFERENCES link(id)
);

Enabling Grafana datasource integration

To enable selection of datasources from an existing Grafana installation, set the --grafana.url flag to the URL of your Grafana installation, as well as either the --grafana.api-token flag (providing an API token directly as a flag) or the --grafana.api-token-file flag (providing an API token from a file).

Creating a Grafana API token

To create an API token suitable for looking up datasources in Grafana:

  • Head to "Configuration > API Keys" in Grafana.
  • Click "Add API key".
  • Give the key a descriptive name, set the "Role" to "Admin", and set its life time to the desired duration (long is recommended, as you will need to regenerate it frequently otherwise).
  • Press "Add" and note down the displayed API key.

Direct links to queries

You can link to a specific query without creating a persisted shared link by appending a q query parameter to the PromLens URL. For example, https://promlens.com/?q=up directly displays and executes the query up. For more complex shared pages, we still recommend creating a full shared page link, as this allows more control over the tree view state, as well as the selected visualization methods.

Architecture

Depending on whether you use advanced features, the PromLens backend has fewer or more responsibilities:

Basic features

When running the PromLens without any link sharing or Grafana integration, the backend is only used to serve static assets and parse PromQL queries into a tree view:

Basic PromLens architecture

Advanced features

If you enable link sharing and/or Grafana datasource integration, the backend also stores and retrieves shared links and connects to Grafana to list datasources and proxy queries:

Advanced PromLens architecture

More Repositories

1

prometheus

The Prometheus monitoring system and time series database.
Go
54,496
star
2

node_exporter

Exporter for machine metrics
Go
10,870
star
3

alertmanager

Prometheus Alertmanager
Go
6,540
star
4

client_golang

Prometheus instrumentation library for Go applications
Go
5,367
star
5

blackbox_exporter

Blackbox prober exporter
Go
4,532
star
6

client_python

Prometheus instrumentation library for Python applications
Python
3,914
star
7

jmx_exporter

A process for exposing JMX Beans via HTTP for Prometheus consumption
Java
3,005
star
8

pushgateway

Push acceptor for ephemeral and batch jobs.
Go
2,969
star
9

client_java

Prometheus instrumentation library for JVM applications
Java
2,166
star
10

mysqld_exporter

Exporter for MySQL server metrics
Go
2,097
star
11

snmp_exporter

SNMP Exporter for Prometheus
Go
1,634
star
12

statsd_exporter

StatsD to Prometheus metrics exporter
Go
912
star
13

cloudwatch_exporter

Metrics exporter for Amazon AWS CloudWatch
Java
892
star
14

procfs

procfs provides functions to retrieve system, kernel and process metrics from the pseudo-filesystem proc.
Go
767
star
15

docs

Prometheus documentation: content and static site generator
SCSS
645
star
16

haproxy_exporter

Simple server that scrapes HAProxy stats and exports them via HTTP for Prometheus consumption
Go
615
star
17

client_ruby

Prometheus instrumentation library for Ruby applications
Ruby
510
star
18

client_rust

Prometheus / OpenMetrics client library in Rust
Rust
462
star
19

consul_exporter

Exporter for Consul metrics
Go
436
star
20

prom2json

A tool to scrape a Prometheus client and dump the result as JSON.
Go
364
star
21

graphite_exporter

Server that accepts metrics via the Graphite protocol and exports them as Prometheus metrics
Go
350
star
22

promu

Prometheus Utility Tool
Go
268
star
23

influxdb_exporter

A server that accepts InfluxDB metrics via the HTTP API and exports them via HTTP for Prometheus consumption
Go
261
star
24

exporter-toolkit

Utility package to build exporters
Go
261
star
25

common

Go libraries shared across Prometheus components and libraries.
Go
261
star
26

collectd_exporter

A server that accepts collectd stats via HTTP POST and exports them via HTTP for Prometheus consumption
Go
255
star
27

memcached_exporter

Exports metrics from memcached servers for consumption by Prometheus.
Go
182
star
28

test-infra

Prometheus E2E benchmarking tool
Go
153
star
29

compliance

A set of tests to check compliance with various Prometheus interfaces
Go
127
star
30

nagios_plugins

Nagios plugins for alerting on Prometheus query results
Shell
103
star
31

demo-site

Demo site auto-deployed with Ansible and Travis CI.
HTML
96
star
32

client_model

Data model artifacts for Prometheus.
Makefile
74
star
33

golang-builder

Prometheus Golang builder Docker images
Shell
69
star
34

codemirror-promql

PromQL support for the CodeMirror code editor
TypeScript
39
star
35

busybox

Prometheus Busybox Docker base images
Makefile
37
star
36

prometheus_api_client_ruby

A Ruby library for reading metrics stored on a Prometheus server
Ruby
36
star
37

talks

Track Prometheus talks
20
star
38

lezer-promql

A lezer-based PromQL grammar
JavaScript
12
star
39

proposals

Design documents for Prometheus Ecosystem
Makefile
9
star
40

host_exporter

See the "node_exporter" repository instead!
8
star
41

circleci

7
star
42

snmp_exporter_mibs

4
star
43

promci

GitHub Actions repository
4
star
44

kube-demo-site

Kubernetes Demo Site
Go
1
star
45

client_java-benchmarks

1
star
46

sigv4

A http.RoundTripper that will sign requests using Amazon's Signature Verification V4 signing procedure
1
star