Prometheus & Grafana

  1. Identify Metrics to Monitor: Identify the metrics that are important for your web application, such as response time, request rate, error rate, CPU usage, memory usage, etc.

  2. Instrument Your Code: Instrument your code to expose these metrics. You can use a Prometheus client library to do this. Prometheus client libraries are available for most popular programming languages, such as Python, Java, Go, and Ruby.

    1. Install the Prometheus client library for your programming language.

    2. Initialize a Prometheus registry object in your code.

    3. Define the metrics you want to expose using the registry object.

    4. Increment the metrics at the appropriate points in your code.

    5. Expose the metrics using an HTTP endpoint.

  3. Configure Prometheus: Configure Prometheus to scrape the metrics exposed by your web application. This involves specifying the endpoint where your application exposes the metrics and defining the scraping frequency.

  4. Visualize Metrics with Grafana: Use Grafana to create dashboards that visualize the metrics collected by Prometheus. Grafana allows you to create graphs, charts, and alerts based on the metrics collected.

  5. Monitor Your Application: Monitor your application using the metrics and dashboards you have created. Use the insights gained from monitoring to improve the performance and reliability of your application.

 

Metrics to Track

  • number of users

  • peak usage time

  • number of downloads

  • district-wise number of clicks

 

Infrastructure:

  • Memory available

  • % CPU time that is used by database processes

  • Available disk space

  • % virtual memory use

Availability:

  • Accessibility of database end point and port

Throughput:

  • Number of active database connections

  • Average time for completing a read query

  • Connection wait time for endpoints

  • Number of read queries in progress or received

  • Average time for completing an update, insert or delete command

  • Number of update, insert, or delete commands that are in progress or received

  • Number of transactions completed

Performance:

  • Number of database lock timeouts

  • Number of read or write queries that are blocked or currently waiting

  • Number of deadlocks

  • Percentage of times the disk-based virtual memory is accessed

  • Queries that run slower than a certain threshold

Security:

  • New user accounts creation

  • Password changes

  • Number of failed login attempts

  • Database configuration change events

Logs:

  • User and system queries

  • Outputs of scheduled jobs

  • Database system events such as errors, startup, shutdown, etc.