This project implements a monitoring stack using Prometheus,Grafana, Loki, and other components to provide observability forapplications and services. It allows users to collect metrics,visualize data, and set up alerts for system performance and health.
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Copy the sample environment file and configure your environment variables:
cp .env.sample .env
-
Ensure Docker and Docker Compose are installed on your machine.
- Prometheus Configuration: Located in
prometheus/prometheus.yml
, this file defines the scrape intervals and targets for metrics collection. - Grafana Dashboards: The dashboards are defined in JSON files located in
grafana/dashboards/
. You can customize these to fit your monitoring needs.
# Start
docker-compose up -d
# Stop
docker-compose down
To ensure that your monitoring stack is configured correctly, you can run the following tests:
-
Check Prometheus Configuration:
./tests/checkConfig.sh
Expected Output:
Checking config file /etc/prometheus/prometheus.yml: SUCCESS
-
Health Check for Containers:
./tests/healthCheck.sh
Expected Output:
ptx_prometheus: running ptx_grafana: running ptx_loki: running
-
Test Prometheus Rules:
./tests/testRules.sh
Expected Output:
Testing rules file /etc/prometheus/test.yml: SUCCESS
Note: The
test.yml
file contains examples for tests and rules. More can be added and customized as needed.
This playground contains:
loki
- storage for logspromtail
that scrapes logs from your/var/log
directory and puts toloki
cadvisor
- exports metrics of running docker containersprometheus
- storage for metrics, get metrics fromcadvisor
, interface: http://localhost:9090 (by default).grafana
: with pre-configured both datasources —loki
andprometheus
. Sample dashboard for node.js app. interface: http://localhost:3000 (by default).
- Install Terraform: Ensure Terraform is installed on your machine.
- Configure Kubernetes: Ensure you have access to your Kubernetes cluster and kubectl is configured.
- Initialize Terraform: Run the following commands from the terraform directory.
cd terraform
terraform init
- Apply the Configuration: Apply the Terraform configuration to create the resources.
terraform apply
- Retrieve Service IP: After applying the configuration, retrieve the service IP.
terraform output consent_manager_service_ip
- Replace placeholder values in the
kubernetes_secret
resource with actual values from your.env
.- Ensure the
server_port
value matches the port used in your application.- Adjust the
host_path
in thekubernetes_persistent_volume
resource to an appropriate path on your Kubernetes nodes.
-
Install Helm: Ensure Helm is installed on your machine. You can install it following the instructions here.
-
Package the Helm chart:
helm package ./path/to/monitoring
-
Deploy the Helm chart:
helm install consent-manager ./path/to/monitoring
-
Verify the deployment:
kubectl get all -n monitoring
-
Retrieve Service IP:
kubectl get svc -n monitoring
- Replace placeholder values in the
values.yaml
file with actual values from your.env
.- Ensure the
port
value matches the port used in your application.
See initial specifications here, Deployment and implementation specification here and Further information here