tao12345666333 commented on code in PR #1683: URL: https://github.com/apache/apisix-ingress-controller/pull/1683#discussion_r1115285660
########## docs/en/latest/monitoring.md: ########## @@ -0,0 +1,125 @@ +--- +title: Monitoring APISIX with Helm Chart +--- + +<!-- +# +# 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. +# +--> + +APISIX has detailed telemetry data. With helm chart, we can easily configure the monitoring system. + +This tutorial will show how to acheive it. + +## Install Prometheus and Grafana + +To collect metrics and visualize them, we need to install Prometheus and Grafana first. + +The APISIX helm chart we will deploy later also contains a `ServiceMonitor` resource, so we should ensure the cluster has its CRD installed. Installing Prometheus will apply the required CRD. + +Run the following command to install Prometheus and Grafana: + +```bash +helm repo add prometheus-community https://prometheus-community.github.io/helm-charts +helm repo update + +helm install -n monitoring prometheus prometheus-community/kube-prometheus-stack \ + --create-namespace \ + --set 'prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false' +``` + +We set option `prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues` to false to force Prometheus watches all service monitors in cluster for test purpose. + +The default Grafana username and password is `admin` and `prom-operator`. + +## Install APISIX + +We should enable service monitor to tell Prometheus collect metrics from APISIX. + +Install APISIX via helm chart with `serviceMonitor.enabled=true` option: + +```bash +helm repo add apisix https://charts.apiseven.com +helm repo update + +helm install apisix apisix/apisix --create-namespace --set serviceMonitor.enabled=true \ + --namespace apisix +``` + +## Configure Grafana Dashboard + + +Import APISIX Grafana dashboard via dashboard ID `11719`. + +The dashboard should be able to display some data, including total requests, handled connections, etc. Routing related panels such as bandwidth and latency will show "No data" because we haven't made any requests yet. Make some requests to make these panels work. + +## Manual Configuration and Troubleshooting + +If you already have an installation of APISIX and Prometheus, you can manually configure `ServiceMonitor` resource and the service that exposes APISIX metrics. + +### Service Monitor and APISIX Service + +The magic behind `serviceMonitor.enabled=true` helmc chart option is `ServiceMonitor` resource. It's content is as follows. Review Comment: ```suggestion The magic behind `serviceMonitor.enabled=true` helm chart option is `ServiceMonitor` resource. Its content is as follows. ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org