Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ services:
- "/var/run/docker.sock:/var/run/docker.sock"
- portainer_data:/data

scraper:
container_name: system_status
build:
context: .
dockerfile: ./status/dockerfile
volumes:
- ./status/health.html:/app/health.html
- ./status/json.json:/app/json.json
restart: 'on-failure'
command:
- --config json.json
- --prometheus_url "http://one.sce/prometheus"
- -vvv


volumes:
alertmanager-data:
grafana-data:
Expand Down
16 changes: 16 additions & 0 deletions status/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# filepath: /Users/vineet/Projects/sce_system_status/prom/Dockerfile.scraper
FROM python:3.9-slim

WORKDIR /app

COPY ./status/requirements.txt .

RUN pip3 install -r requirements.txt

COPY ./status/flags.py .

COPY ./status/scraper.py .

COPY ./status/health.html /app/health.html

ENTRYPOINT ["python3", "scraper.py"]
93 changes: 93 additions & 0 deletions status/health.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<!DOCTYPE html>
<html>
<head>
<title>Prometheus Metrics</title>
<style>
body {
font-family: 'Roboto', Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f3f4f6;
color: #333;
}
h1 {
color: #222;
font-size: 28px;
text-align: center;
margin: 20px 0;
}
p {
text-align: center;
font-size: 16px;
color: #555;
margin-bottom: 20px;
}
table {
border-collapse: collapse;
width: 90%;
margin: 0 auto;
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
background-color: #fff;
border-radius: 8px;
overflow: hidden;
}
th, td {
border: 1px solid #ddd;
padding: 15px;
text-align: center;
}
th {
background-color: #007BFF;
color: white;
font-size: 18px;
text-transform: uppercase;
}
td {
font-size: 16px;
}
.healthy {
color: #28a745;
font-weight: bold;
}
.unhealthy {
color: #dc3545;
font-weight: bold;
}
.tie {
color: #17a2b8;
font-weight: bold;
}
tr:nth-child(even) {
background-color: #f8f9fa;
}
tr:hover {
background-color: #e9ecef;
cursor: pointer;
}
footer {
text-align: center;
margin-top: 20px;
font-size: 14px;
color: #666;
}
</style>
</head>
<body>
<h1>Prometheus Metrics</h1>
<p>Last updated: {{ timestamp }}</p>
<table>
<tr>
<th>Job</th>
<th>Status</th>
</tr>
{% for item in metrics %}
<tr>
<td>{{ item.job }}</td>
<td class="{% if item.status == 'Healthy' %}healthy{% else %}unhealthy{% endif %}">
{{ item.status }}
</td>
</tr>
{% endfor %}
</table>
</body>
</html>
6 changes: 6 additions & 0 deletions status/json.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"job-id": "prometheus-aggregation",
"query": "up"
}
]
31 changes: 31 additions & 0 deletions status/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
http {
# Define cache path and parameters
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=html_cache:10m max_size=100m inactive=60m;
proxy_temp_path /var/cache/nginx/temp;

#for http://localhost/status
server{
listen 80;
server_name _;

# Enable caching
proxy_cache html_cache;
proxy_cache_valid 200 302 30s;
proxy_cache_valid 404 30s;

location /{
proxy_pass http://scraper:8000;

# Cache HTML files
location ~* \.html$ {
proxy_pass http://scraper:8000;
proxy_cache html_cache;
proxy_cache_min_uses 1;
proxy_cache_lock on;
add_header X-Cache-Status $upstream_cache_status;
}
}
}
}

events{ }
6 changes: 6 additions & 0 deletions status/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fastapi==0.84.0
uvicorn==0.18.3
Jinja2==3.0.2
py-grpc-prometheus==0.7.0
prometheus_api_client==0.4.0

Loading