Log Viewer

Grafana, Loki, and Promtail Working Together to View Gower Logs via Web

Grafana

Grafana is an open-source data visualization and monitoring platform that supports multiple data sources, including Graphite, InfluxDB, Prometheus, Elasticsearch, and more. It allows for real-time querying, visualization, and alerting of data from these sources.

Grafana provides various visualization options through custom plugins and panels, such as line charts, bar charts, heatmaps, dashboards, maps, and more.

Configure Account and Password

third_apps\grafana\share\conf\defaults.ini

.
.
.
#################################### Security ############################
[security]
# disable creation of admin user on first start of grafana
disable_initial_admin_creation = false

# default admin user, created on startup
admin_user = admin

# default admin password, can be changed before first start of grafana, or in profile settings
admin_password = admin
.
.
.

Start

The standard local release version depends on Grafana, so there’s no need to start Grafana separately.

    depends_on:
      - caddy
      - tidb
      - mysql
      - grafana

It is recommended to use a script to run the application.

$ ./docker/run-dev

Access Grafana

http://localhost:3000

Login

Enter the account and password configured above.

Add Data Source

Mainly add the Loki data source.

Select Loki

Configure Loki Request

Enter http://loki:3100 in the URL.

Save and Test

Two checkmarks indicate that the data source has been added successfully and labels have been retrieved successfully. If label retrieval fails, it may be because no logs have been generated in the directory.

Explore

Click the explore button in the left menu.

Configuration

Configure as shown in the image:

Select Task

Choose filename or job, then select the specific log file or task.

Delete Line Contains
Add JSON Formats
Add Label Filter
Run Query

View Logs

Filter Time

Loki

Loki is a data source provided by Grafana Labs. Its role is to provide a data interface for Grafana, with the default listening port being 3100.

It also provides a log data push interface for Promtail.

Promtail

Promtail is a local log aggregation driver that reads log data and pushes it to Loki via its push interface, making the data available for Grafana to use.