Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Grafana Dashboard Configuration #731

Merged
merged 6 commits into from
Dec 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/assets/images/dashboard_view_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/dashboard_view_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/dashboard_view_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/datasource_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/datasource_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/grafana.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/import_via_panel_json.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/metrics_data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
848 changes: 848 additions & 0 deletions docs/assets/other/json/apisix-ingress-controller-grafana.json

Large diffs are not rendered by default.

124 changes: 124 additions & 0 deletions docs/en/latest/plugins/prometheus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---
title: prometheus
---

<!--
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
-->

This guide shows how to monitor Apache APISIX Ingress Controller using Prometheus and Grafana.

## Enable Prometheus

Use CRD file to enable Prometheus in global configurations. The definition file for custom resources is `ApisixClusterConfig`, so the configuration should be:

```yaml
Sindweller marked this conversation as resolved.
Show resolved Hide resolved
apiVersion: apisix.apache.org/v2beta3
kind: ApisixClusterConfig
metadata:
name: default
spec:
monitoring:
prometheus:
enable: true
```

## Configure Prometheus Server

The Prometheus server address should be `127.0.0.1:9090` by default. You can set the target url for `apisix-ingress-controller` manually in `prometheus.yml`.
For example:

```yaml
...
scrape_configs:
- job_name: "apisix-ingress-controller"
static_configs:
- targets: ["localhost:9092"]
```

According to the above example, the metrics are exposed in `http://localhost:9092/metrics` now.
Visit `http://localhost:9090` in your browser, and select `apisix-ingress-controller` in `targets`
or visit `http://localhost:9092/metrics` to see the data.
![metrics_data.png](../../../assets/images/metrics_data.png)

## Grafana Dashboard

Grafana dashboard shows the metrics exposed in Prometheus graphically.
[Installing Grafana](https://grafana.com/docs/grafana/latest/#installing-grafana)
Visit `http://localhost:3000/` in your browser to access Grafana. The default username and password are `admin`.
Then create a new dashboard for `apisix-ingress-controller`.
![grafana.png](../../../assets/images/grafana.png)
Follow the steps to apply the configuration of Grafana Dashboard for `apisix-ingress-controller`.

- Add an empty panel, and import via panel json in `apisix-ingress-controller/docs/assets/other/json/apisix-ingress-controller-grafana.json`.
![img.png](../../../assets/images/img.png)
![import_via_panel_json.png](../../../assets/images/import_via_panel_json.png)
- Select `Prometheus database` as the datasource. Set the URL according to your Prometheus server configuration.
![datasource_1.png](../../../assets/images/datasource_1.png)
![datasource_2.png](../../../assets/images/datasource_2.png)

### Preview

![dashboard_view_1.png](../../../assets/images/dashboard_view_1.png)
![dashboard_view_2.png](../../../assets/images/dashboard_view_2.png)
![dashboard_view_3.png](../../../assets/images/dashboard_view_3.png)

## Available metrics

- `Is leader` A gauge type metric with value 0 or 1, indicates whether the role of controller instance is leader, for leader is 1 and candidate is 0.
Labels:
- controller_pod
- controller_namespace
- `Status codes` status codes of requests to APISIX.
Labels:
- controller_pod
- controller_namespace
- status_code: the HTTP status code returned by APISIX.
- resource
- `Latency` Request latencies with APISIX.
Labels:
- controller_pod
- controller_namespace
- `Requests` Number of requests to APISIX.
Labels:
- controller_pod
- controller_namespace
- resource
- `Check cluster health` Number of cluster health check operations.
Labels:
- controller_pod
- controller_namespace
- name: cluster name.
- `Sync operation` Number of sync operations.
Labels:
- controller_pod
- controller_namespace
- resource
- result: sync success or failure.
- `Cache sync` Number of cache sync operations.
Labels:
- controller_pod
- controller_namespace
- result: sync success or failure.
- `Controller events` Number of events handled by the controller.
Labels:
- controller_pod
- controller_namespace
- resource
- operation: includes `add`, `update`, `delete`.