-
Download Prometheus:
- Visit the Prometheus download page.
- Download the Windows ZIP file for the latest version (e.g.,
prometheus-2.53.3.windows-amd64).
-
Extract Prometheus:
-
Extract the ZIP file to a folder. For example:
C:\Users\Kumar\OneDrive\Desktop\projects\grafana_promethus\prometheus-2.53.3.windows-amd64 -
Open PowerShell and navigate to the folder:
cd "C:\Users\Kumar\OneDrive\Desktop\projects\grafana_promethus\prometheus-2.53.3.windows-amd64"
-
-
Verify Installation:
-
Run the following command to check Prometheus is installed correctly:
.\prometheus.exe --version
-
- Modify the
prometheus.ymlFile:-
Open the
prometheus.ymlconfiguration file:code "C:\Users\Kumar\OneDrive\Desktop\projects\grafana_promethus\prometheus-2.53.3.windows-amd64\prometheus.yml" -
Add a job for Windows Exporter under
scrape_configs:scrape_configs: - job_name: 'windows_exporter' scrape_interval: 5s static_configs: - targets: ['localhost:9182'] -
Start Prometheus:
-
Run Prometheus using:
.\prometheus.exe --config.file=prometheus.yml
-
-
Access Prometheus:
-
Open your browser and go to:
http://localhost:9090
-
-
-
Download the MSI Installer:
- Visit the Windows Exporter GitHub page.
- Download the latest
.msiinstaller.
-
Run the Installer:
- Double-click the MSI file and follow these steps:
- Choose the default installation path (e.g.,
C:\WindowsExporter). - Enable the Firewall Exception during setup.
- Leave the list of collectors as
[defaults].
- Choose the default installation path (e.g.,
- Double-click the MSI file and follow these steps:
-
Start Windows Exporter:
-
Navigate to the installation folder and run:
.\windows_exporter.exe
-
-
Verify Windows Exporter:
-
Open your browser and check:
http://localhost:9182/metrics
-
-
Download Grafana:
- Visit the Grafana download page.
- Download the Windows installer for the latest version (e.g.,
grafana-11.5.2).
-
Run the Installer:
-
Install Grafana using the default path:
C:\Program Files\GrafanaLabs\grafana
-
-
Start the Grafana Server:
-
Navigate to the Grafana installation folder and run:
cd "C:\Program Files\GrafanaLabs\grafana" .\bin\grafana-server.exe
-
-
Access Grafana:
-
Open your browser and go to:
http://localhost:3000 -
Log in with the default credentials:
- Username:
admin - Password:
admin
- Username:
-
Change the password when prompted( i set my own password : sammyouel)
-
- Add Prometheus as a Data Source:
- In Grafana, go to Connections → Data Sources → Add Data Source.
- Choose Prometheus from the list.
- Configure it with:
- URL:
http://localhost:9090 - Access:
Server (default)
- URL:
- Click Save & Test.
- Verify the Connection:
- If successful, you’ll see the message: "Data source is working."
- Start Visualizing:
- Begin building your dashboard using metrics from Prometheus (e.g., CPU usage, memory usage).
Enter the PromQL Query:
windows_cpu_time_total :
Enter the PromQL Query:
go_memstats_alloc_bytes:
Create a single PowerShell script to start Prometheus, Grafana, and Windows Exporter together.
-
Create the Script File:
- Open a new file in VS Code and name it
start_monitoring.ps1.
- Open a new file in VS Code and name it
-
Add the Following Script:
# Start Prometheus Start-Process -FilePath "C:\Prometheus\prometheus.exe" -WindowStyle Minimized # Start Grafana Start-Process -FilePath "C:\Program Files\GrafanaLabs\grafana\bin\grafana-server.exe" -WindowStyle Minimized # Start Windows Exporter Start-Process -FilePath "C:\WindowsExporter\windows_exporter.exe" -WindowStyle Minimized Write-Output "All monitoring tools started successfully." -
Run the Script:
-
Execute the script in PowerShell:
.\start_monitoring.ps1
-
-
Add the Script to Startup:
-
Place the script in the Startup folder to run it automatically on system boot:
$startupPath = [Environment]::GetFolderPath("Startup") Copy-Item -Path "C:\YourPath\start_monitoring.ps1" -Destination
-
$startupPath = [Environment]::GetFolderPath("Startup")
$startupPath
Next :
$startupPath = [Environment]::GetFolderPath("Startup")
Copy-Item -Path "C:\Users\Kumar\OneDrive\Desktop\projects\grafana_promethus\prometheus-2.53.3.windows-amd64\start_monitoring.ps1" -Destination $startupPath
-
Paste the above script into your PowerShell console or script editor.
-
Execute it by pressing Enter.
-
Confirm the file was copied successfully by checking the Startup folder:
powershell
Test-Path "$startupPath\start_monitoring.ps1"If it returns
True, the script was successfully added to the Startup folder.
Adding alerts for high CPU usage or low memory situations is essential for proactive monitoring.
-
Edit
prometheus.ymlto Define Alerts:-
Open the
prometheus.ymlfile in your Prometheus directory:code "C:\Users\Kumar\OneDrive\Desktop\projects\grafana_promethus\prometheus-2.53.3.windows-amd64\prometheus.yml" -
Add an
alertingrule configuration:rule_files: - "C:/Users/Kumar/OneDrive/Desktop/projects/grafana_promethus/prometheus-2.53.3.windows-amd64/alert.rules.yml"
-
-
Create an
alert.rules.ymlFile:-
In the same directory, create the
alert.rules.ymlfile:code "C:\Users\Kumar\OneDrive\Desktop\projects\grafana_promethus\prometheus-2.53.3.windows-amd64\alert.rules.yml" -
Add the following example alert rules to the yaml file:
groups:
- name: System Alerts
rules:
- alert: HighCPUUsage expr: sum(rate(windows_cpu_time_total[1m])) > 0.75 for: 2m labels: severity: critical annotations: summary: High CPU usage detected description: CPU usage has exceeded 75% for more than 2 minutes. Investigate immediately.
- alert: LowMemoryAvailable expr: windows_memory_available_bytes / windows_memory_total_bytes < 0.20 for: 2m labels: severity: warning annotations: summary: Low Memory Warning description: Available memory is less than 20% of the total memory for over 2 minutes.
- name: System Alerts
rules:
-
Restart Prometheus to Apply Changes
-
Save both
prometheus.ymlandalert.rules.yml. -
Restart Prometheus to load the new configurations:
powershell
cd "C:\Users\Kumar\OneDrive\Desktop\projects\grafana_promethus\prometheus-2.53.3.windows-amd64" .\prometheus.exe --config.file=prometheus.yml -
Verify Alerts in Prometheus:
- Go to
http://localhost:9090/alertsto view active alerts.
- Go to
-
Ensure Your Project Is on GitHub:
-
If it’s not already, push your project to a GitHub repository:
bash
git init git add . git commit -m "Initial commit" git branch -M main git remote add origin <your-repo-URL> git push -u origin main
-
-
Create a Workflow File:
- Navigate to your repository on GitHub.
- Go to the Actions tab → New Workflow → Set up a workflow yourself.
- Create a file named
.github/workflows/ci-cd-pipeline.yml.
-
Add the Following Workflow:
yaml
`name: CI/CD Pipeline for Monitoring Project
on: push: branches: - main
jobs: build: runs-on: windows-latest
steps: - name: Checkout Code uses: actions/checkout@v3 - name: Validate Prometheus Config run: | prometheus.exe --config.file=prometheus.yml --dry-run - name: Validate Alert Rules run: | prometheus.exe --config.file=prometheus.yml --rules.alerts.alertmanager.rulestest: runs-on: windows-latest needs: build
steps: - name: Checkout Code uses: actions/checkout@v3 - name: Test Prometheus Connection run: | curl http://localhost:9090/api/v1/alertsdeploy: runs-on: windows-latest needs: test
steps: - name: Deploy Updates run: | # Any deployment-specific commands go here, e.g., restart services` -
Save and Push the Workflow:
- Commit the
.github/workflows/ci-cd-pipeline.ymlfile. - Push it to the
mainbranch.
- Commit the
-
Run the Workflow:
- Every time you push changes to the repository, GitHub Actions will automatically trigger the pipeline.
-
Created a dedicated directory named
code_directorywithin the main project folder:C:\Users\Kumar\OneDrive\Desktop\projects\grafana_promethus\prometheus-2.53.3.windows-amd64\code_directory -
Moved all custom scripts and files (e.g.,
start_monitoring.ps1) into thecode_directoryfor better organization.
-
Adjusted paths in
start_monitoring.ps1to ensure compatibility with the new project structure:powershell
# Example: Start-Process -FilePath "C:\Users\Kumar\OneDrive\Desktop\projects\grafana_promethus\prometheus-2.53.3.windows-amd64\prometheus.exe" -WindowStyle Minimized -
Verified that all services (Prometheus, Grafana, and Windows Exporter) start successfully from the script.
-
Configured Git with your username and email:
bash
git config --global user.name "sammyouel" git config --global user.email "[email protected]" -
Added a
.gitignorefile to exclude unnecessary files and folders:plaintext
prometheus.exe promtool.exe alertmanager.exe data/ logs/ console_libraries/ consoles/ *.zip *.tar.gz .vscode/ !prometheus.yml !alert.rules.yml !LICENSE !NOTICE !README.md
-
Encountered and resolved merge conflicts in
README.md. Combined or prioritized content as needed:plaintext
# monitoring-project our grafana-promethus integrated code base -
Marked the conflict as resolved:
bash
git add README.md git commit -m "Resolved merge conflict in README.md"
- Set up a new GitHub repository to host the reorganized project:
-
Repository Name:
monitoring-project. -
Added the new repository as the remote:
bash
git remote add origin https://github.com/sammyouel/monitoring-project.git
-
-
Initialized Git in the main project directory and pushed the changes:
bash
git init git add . git commit -m "Initial commit for reorganized project" git branch -M main git push -u origin main
-
Ran the
start_monitoring.ps1script:powershell
pwsh -File "C:\Users\Kumar\OneDrive\Desktop\projects\grafana_promethus\prometheus-2.53.3.windows-amd64\code_directory\start_monitoring.ps1" -
Confirmed the following:
- Prometheus was accessible at
http://localhost:9090. - Grafana was accessible at
http://localhost:3000. - Windows Exporter metrics were available at
http://localhost:9182/metrics.
- Prometheus was accessible at
- Shared Repository:
- Shared the GitHub repository link with collaborators.
- Included
LICENSE,README.md,NOTICE, and other critical files for better project clarity.
- Deployed Dashboards:
- Set up Prometheus and Grafana on a local/remote server.
- Shared dashboard access via:
http://<server-IP>:9090for Prometheus.http://<server-IP>:3000for Grafana.
- Optionally secured access using SSL and user authentication.








