All Projects → ricoberger → loki_exporter

ricoberger / loki_exporter

Licence: MIT License
Prometheus exporter to collect metrics and run queries against the Grafana Loki API.

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to loki exporter

Pihole Exporter
A Prometheus exporter for PI-Hole's Raspberry PI ad blocker
Stars: ✭ 352 (+1157.14%)
Mutual labels:  grafana, prometheus, prometheus-exporter
Unifiedmetrics
Fully-featured metrics collection agent for Minecraft servers. Supports Prometheus and InfluxDB. Dashboard included out-of-box.
Stars: ✭ 29 (+3.57%)
Mutual labels:  grafana, prometheus, prometheus-exporter
docker-prometheus
A minimal Prometheus Server, Node Exporter, BlackBox Exporter and Grafana implementation with `docker-compose`.
Stars: ✭ 71 (+153.57%)
Mutual labels:  grafana, prometheus, alertmanager
Promcord
📊 Analyze your entire discord guild in grafana using prometheus. Message, User, Game and Voice statistics...
Stars: ✭ 39 (+39.29%)
Mutual labels:  grafana, prometheus, prometheus-exporter
Jira Prometheus Exporter
Prometheus Exporter For JIRA
Stars: ✭ 113 (+303.57%)
Mutual labels:  grafana, prometheus, prometheus-exporter
Prometheus Book
Prometheus操作指南
Stars: ✭ 2,637 (+9317.86%)
Mutual labels:  grafana, prometheus, alertmanager
Dockprom
Docker hosts and containers monitoring with Prometheus, Grafana, cAdvisor, NodeExporter and AlertManager
Stars: ✭ 4,489 (+15932.14%)
Mutual labels:  grafana, prometheus, alertmanager
Druid Exporter
A Golang based exporter captures druid API related metrics and receives druid-emitting HTTP JSON data.
Stars: ✭ 54 (+92.86%)
Mutual labels:  grafana, prometheus, prometheus-exporter
Citrix Adc Metrics Exporter
Export metrics from Citrix ADC (NetScaler) to Prometheus
Stars: ✭ 67 (+139.29%)
Mutual labels:  grafana, prometheus, prometheus-exporter
Loki
Like Prometheus, but for logs.
Stars: ✭ 14,483 (+51625%)
Mutual labels:  grafana, prometheus, loki
Awesome Prometheus Alerts
🚨 Collection of Prometheus alerting rules
Stars: ✭ 3,323 (+11767.86%)
Mutual labels:  grafana, prometheus, alertmanager
starboard-exporter
A standalone exporter for vulnerability reports and other CRs created by Starboard.
Stars: ✭ 22 (-21.43%)
Mutual labels:  prometheus, prometheus-exporter
github exporter
Prometheus exporter for GitHub
Stars: ✭ 21 (-25%)
Mutual labels:  prometheus, prometheus-exporter
zfs exporter
Prometheus ZFS exporter
Stars: ✭ 52 (+85.71%)
Mutual labels:  prometheus, prometheus-exporter
epiphany
Cloud and on-premises automation for Kubernetes centered industrial grade solutions.
Stars: ✭ 114 (+307.14%)
Mutual labels:  grafana, prometheus
nvidia gpu exporter
Nvidia GPU exporter for prometheus using nvidia-smi binary
Stars: ✭ 85 (+203.57%)
Mutual labels:  prometheus, prometheus-exporter
octane-exporter
Export Laravel Octane metrics using this Prometheus exporter.
Stars: ✭ 14 (-50%)
Mutual labels:  grafana, prometheus
sentry exporter
Prometheus exporter for Sentry
Stars: ✭ 23 (-17.86%)
Mutual labels:  prometheus, prometheus-exporter
deluge exporter
Prometheus exporter for the Deluge BitTorrent client
Stars: ✭ 24 (-14.29%)
Mutual labels:  prometheus, prometheus-exporter
cdn-up-and-running
CDN Up and Running - an introduction about how modern CDNs works
Stars: ✭ 131 (+367.86%)
Mutual labels:  grafana, prometheus

loki_exporter

The loki_exporter is a Prometheus exporter for Loki. Loki is a horizontally-scalable, highly-available, multi-tenant log aggregation system from the creators of Grafana. The loki_exporter runs queries against the Loki API and returns the number of entries for each stream. This exporter is designed to detect critical log events, where the results can be used to create alerts in Prometheus.

Building and running

To run the loki_exporter you can use the prebuild binaries or the official Docker image from Docker Hub.

Local Build

make build
./bin/loki_exporter <flags>

Visiting http://localhost:9524/metrics will return metrics for all queries. The loki_success metric indicates if the execution of the queries succeeded.

Building with Docker

docker build -t loki_exporter .
docker run -d -p 9524:9524 --name loki_exporter -v `pwd`:/config loki_exporter --config.file=/config/config.yml

Usage and configuration

The loki_exporter is configured via a configuration file and command-line flags.

Usage of ./bin/loki_exporter:
  -config.file string
    	Configuration file in YAML format. (default "config.yml")
  -version
    	Show version information.
  -web.listen-address string
    	Address to listen on for web interface and telemetry. (default ":9524")
  -web.telemetry-path string
    	Path under which to expose metrics. (default "/metrics")

The configuration file is written in YAML format, defined by the scheme described below.

# ======================== loki_exporter configuration =========================
#
# The loki_exporter is a Prometheus exporter for Loki. Loki is a
# horizontally-scalable, highly-available, multi-tenant log aggregation system
# from the creators of Grafana. The loki_exporter runs queries against the Loki
# API and returns the number of entries for each stream. This exporter is
# designed to detect critical log events, where the results can be used to
# create alerts in Prometheus.
#
# ------------------------------------ Loki ------------------------------------
#
loki:
  listenAddress: <string>
  basicAuth:
    enabled: <boolean>
    username: <string>
    password: <string>
#
# ---------------------------------- Metrics -----------------------------------
#
metrics:
  labels: <boolean>
  labelValues: <boolean>
  queries: <boolean>
#
# ---------------------------------- Queries -----------------------------------
#
queries:
  - name: <string>
    query: <string>
    limit: <integer>
    start: <string>
    end: <string>
    direction: <string>

The configuration file is divided into three sections. The loki section is used for the configuration of the Loki API endpoint. The default value for the listenAddress is http://localhost:3100 and basic authentication is disabled by default.

The metrics section enables/disables the different type of metrics, which should be exported.

The queries section represents all queries which should be run against the Loki API. The parameters and default values can be found in the following table:

Parameter Description Default Value
name A custom name for the query. The name is used for the exported metric: loki_query_name
query Query must be a logQL query.
limit Maximum number of entries which should be returned by the Loki API. -1
start The start time for the query. Must be a valid golang duration string. The duration is added to the current time. -24h
end The end time for the query. Must be a valid golang duration string. The duration is added to the current time. 0s
direction Search direction must be forward or backward, useful when specifying a limit.

Example

The example is based on the official example from the Loki documentation. Clone the repository, go to the examples folder and run the docker-compose file. The docker-compose file will start a docker image for Loki, Promtail, Grafana, Prometheus and the loki_exporter.

git clone https://github.com/ricoberger/loki_exporter.git
cd loki_exporter/example
docker-compose up

Visiting the loki_exporter output on http://localhost:9524. The output will look like the one at the end of this section. You can also open the Prometheus dashboard on http://localhost:9090. There you can find the loki_ metrics if in one of you log files under /var/logs an error occured.

# HELP loki_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which loki_exporter was built.
# TYPE loki_exporter_build_info gauge
loki_exporter_build_info{branch="master",goversion="go1.11",revision="841cbe36cf84fcf6f0a61d33e16930c63d12792c",version="v0.1.0-1-g841cbe3"} 1
# HELP loki_exporter_total_scrapes Current total loki scrapes.
# TYPE loki_exporter_total_scrapes counter
loki_exporter_total_scrapes 2
# HELP loki_label_values_total total number of label values
# TYPE loki_label_values_total gauge
loki_label_values_total{label="__filename__"} 26
loki_label_values_total{label="job"} 1
# HELP loki_labels_total total number of label
# TYPE loki_labels_total gauge
loki_labels_total 2
# HELP loki_query_varlogs_total number of entries
# TYPE loki_query_varlogs_total gauge
loki_query_varlogs_total{filename="/var/log/docker.log",job="varlogs"} 165
loki_query_varlogs_total{filename="/var/log/docker.log.0",job="varlogs"} 33
loki_query_varlogs_total{filename="/var/log/kmsg.log",job="varlogs"} 3
loki_query_varlogs_total{filename="/var/log/vpnkit-forwarder.log",job="varlogs"} 183
loki_query_varlogs_total{filename="/var/log/vsudd.log",job="varlogs"} 7
loki_query_varlogs_total{filename="/var/log/vsudd.log.0",job="varlogs"} 6
# HELP loki_success Was the last scrape of loki successful.
# TYPE loki_success gauge
loki_success 1

Dependencies

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].