Search code examples
kubernetescontainersmonitoringprometheusreact-fullstack

How to monitor a container running db2 image using Prometheus and also react app using Prometheus?


I have to build a monitoring solution using Prometheus and Graphana for a service which is built using React(front end)+ Node js + Db2(containerised) . I have no idea where to start,can someone suggest me the resources where to learn?Thank you.


Solution

  • First of all, you need to install Prometheus and Grafana in your Kubernetes cluster following the instructions given for each:

    Prometheus: https://prometheus.io/docs/prometheus/latest/installation/

    Grafana: https://grafana.com/docs/grafana/latest/installation/

    Next, you need to understand that Prometheus is a pull-based metrics collection system. It retrieves metrics from configured targets (endpoints) at given intervals and displays the results.

    You can setup the working monitoring system by implementing the below steps:

    1. Instrument your application code for Prometheus to be able to scrape metric from - For this, you need to add instrumentation to the code via one of the supported Prometheus client libraries.
    2. Configure Prometheus to scrape the metrics exposed by the service - Prometheus supports a K8s custom resource named ServiceMonitor introduced by the Prometheus Operator that can be used to configure Prometheus to scrape the metric defined in step 1.
    3. Observe the scraped metrics - Next, you can observe the defined metric in either the Prometheus UI or Grafana UI by configuring Grafana support for Prometheus.