Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/dashboards.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI Dashboards QA
name: CI Dashboards QA

on:
push:
Expand Down
85 changes: 85 additions & 0 deletions bit-blocks-starter/observability/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Observability 📊 | BitBlock Starter Pack

The **Observability** module of the BitBlock Starter Pack gives you instant, production-ready visibility into your cloud-native apps and infrastructure—right out of the box.

Designed for DevOps, SREs, solo founders, and platform teams, this folder helps you quickly add world-class monitoring, cost transparency, and logging with minimal setup.


## 📂 Folder Structure

```
observability/
├── cost-monitoring/
├── dashboards/
├── metrics/
└── logging/
```

### What’s Inside

- **cost-monitoring/**
Pre-built workflows, configs, and queries for cloud and Kubernetes cost visibility.
*Use this to track spend by service, namespace, team, or project. Get actionable insights and alerts for smarter budgeting and resource allocation.*

- **dashboards/**
Ready-to-import Grafana dashboards for key SRE, infrastructure, business, and cost metrics.
*Jumpstart your monitoring: Copy, customize, and connect to your data sources for instant observability.*

- **metrics/**
Sample Prometheus metrics and starter queries.
*Ideal for demos, onboarding, or building your first dashboards. Replace with real exporters in production environments.*

- **logging/**
Example configs and patterns for collecting, parsing, and visualizing logs.
*Integrate with popular tools (e.g., Loki) for end-to-end visibility from application to infrastructure.*

---

## 🚀 Quick Start

1. **Set Up Your Stack:**
Deploy Prometheus, Grafana, and your preferred logging backend (e.g., Loki, ELK).

2. **Import Dashboards:**
Load dashboards from `/dashboards` into Grafana to get immediate visibility.

3. **Connect Cost & Metrics Data:**
- Point `/metrics` samples to Prometheus for demo data, or wire up your exporters for live environments.
- Use `/cost-monitoring` configs for real-time cost insights.

4. **Enable Logging:**
Apply patterns and configs in `/logging` to ship, parse, and search logs across your environment.

5. **Customize & Extend:**
Adapt dashboards, queries, and alerts to your team’s needs.

---

## 🛠️ Use Cases

- Track Kubernetes and cloud costs across teams and projects.
- Monitor SRE metrics: reliability, performance, error budgets, incidents.
- Visualize infrastructure, application, and business KPIs.
- Centralize and search logs for rapid troubleshooting and audits.

---

## 💡 Best Practices

- Use the sample metrics and configs for demos or quick starts—swap in production data as you go.
- Version-control all dashboards and observability configs to keep your monitoring stack consistent.
- Review and customize alerts, thresholds, and variables to fit your unique environment.

---

## 🤝 Contributions

Have a killer dashboard or cost query?
Want to help others monitor smarter?
Open a PR or issue—let’s make cloud-native observability effortless for everyone.

---

Happy shipping & scaling 🚀
*— BitBlock Team*

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
groups:
- name: cloud-cost-alerts
rules:
- alert: CloudMonthlyBudgetExceeded
expr: sum(cloud_cost_total) > 5000
for: 10m
labels:
severity: critical
annotations:
summary: "Cloud spend above budget"
description: "Cloud spend this month has exceeded $5,000. Review your cloud resources and billing details."

- alert: CloudDailySpendSpike
expr: increase(cloud_cost_total[1d]) > 1.2 * avg_over_time(increase(cloud_cost_total[1d])[7d:1d])
for: 10m
labels:
severity: warning
annotations:
summary: "Cloud daily spend anomaly"
description: "Today's cloud spend is over 20% higher than the 7-day daily average. Investigate recent deployments or spikes."

- alert: TopCloudServiceOverspend
expr: topk(1, sum(cloud_cost_total) by (service)) > 2000
for: 10m
labels:
severity: warning
annotations:
summary: "Top cloud service overspending"
description: "The top cloud service ({{ $labels.service }}) is spending over $2,000 this month."
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"id": null,
"uid": "cloud-cost-billing",
"title": "Cloud Cost & Billing Analytics",
"tags": ["cost", "cloud", "billing", "analytics"],
"timezone": "browser",
"schemaVersion": 36,
"version": 1,
"refresh": "1h",
"style": "dark",
"editable": true,
"panels": [
{
"type": "stat",
"title": "Total Cloud Spend (This Month)",
"gridPos": { "x": 0, "y": 0, "w": 6, "h": 4 },
"datasource": "${DS_PROMETHEUS}",
"targets": [
{
"expr": "sum(cloud_cost_total{period='month'})",
"legendFormat": "Total"
}
],
"fieldConfig": { "defaults": { "unit": "currency", "decimals": 2 } }
},
{
"type": "stat",
"title": "Total Cloud Spend (This Week)",
"gridPos": { "x": 6, "y": 0, "w": 6, "h": 4 },
"datasource": "${DS_PROMETHEUS}",
"targets": [
{
"expr": "sum(cloud_cost_total{period='week'})",
"legendFormat": "Total"
}
],
"fieldConfig": { "defaults": { "unit": "currency", "decimals": 2 } }
},
{
"type": "bar",
"title": "Cloud Spend by Provider",
"gridPos": { "x": 0, "y": 4, "w": 12, "h": 6 },
"datasource": "${DS_PROMETHEUS}",
"targets": [
{
"expr": "sum by(provider) (cloud_cost_total{period='month'})",
"legendFormat": "{{provider}}"
}
],
"fieldConfig": { "defaults": { "unit": "currency", "decimals": 2 } }
},
{
"type": "table",
"title": "Top 5 Services by Cost",
"gridPos": { "x": 0, "y": 10, "w": 12, "h": 7 },
"datasource": "${DS_PROMETHEUS}",
"targets": [
{
"expr": "topk(5, sum by(service) (cloud_cost_service_total{period='month'}))",
"legendFormat": "{{service}}"
}
],
"fieldConfig": { "defaults": { "unit": "currency", "decimals": 2 } }
},
{
"type": "timeseries",
"title": "Cost Trend (Last 30 Days)",
"gridPos": { "x": 0, "y": 17, "w": 12, "h": 6 },
"datasource": "${DS_PROMETHEUS}",
"targets": [
{
"expr": "sum by(date) (cloud_cost_daily{provider=~'.*'})",
"legendFormat": "Daily Spend"
}
],
"fieldConfig": { "defaults": { "unit": "currency", "decimals": 2 } }
},
{
"type": "stat",
"title": "Cost Forecast (Next 30 Days)",
"gridPos": { "x": 0, "y": 23, "w": 6, "h": 4 },
"datasource": "${DS_PROMETHEUS}",
"targets": [
{
"expr": "predict_linear(cloud_cost_daily[30d], 30*24*60*60)",
"legendFormat": "Forecast"
}
],
"fieldConfig": { "defaults": { "unit": "currency", "decimals": 2 } }
},
{
"type": "stat",
"title": "Budget/Threshold Alert",
"gridPos": { "x": 6, "y": 23, "w": 6, "h": 4 },
"datasource": "${DS_PROMETHEUS}",
"targets": [
{
"expr": "max_over_time(cloud_cost_total{period='month'}[30d]) > on() budget_limit",
"legendFormat": "Over Budget"
}
],
"fieldConfig": { "defaults": { "unit": "none" } }
},
{
"type": "stat",
"title": "Anomaly Detector",
"gridPos": { "x": 0, "y": 27, "w": 12, "h": 4 },
"datasource": "${DS_PROMETHEUS}",
"targets": [
{
"expr": "sum_over_time(cloud_cost_anomaly[1d])",
"legendFormat": "Detected Anomalies"
}
],
"fieldConfig": { "defaults": { "unit": "none" } }
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
groups:
- name: kubecost-k8s-cost-alerts
rules:
- alert: K8sClusterMonthlySpendHigh
expr: sum(kubecost_cluster_cost_total) > 2000
for: 10m
labels:
severity: warning
annotations:
summary: "K8s cluster monthly spend high"
description: "The total K8s cluster spend this month is over $2,000. Investigate workloads and resource allocations."

- alert: K8sNamespaceOverspend
expr: sum(kubecost_namespace_cost_total) by (namespace) > 1000
for: 10m
labels:
severity: warning
annotations:
summary: "K8s namespace overspending"
description: "Namespace {{ $labels.namespace }} is spending over $1,000 this month. Review for cost optimization."

- alert: K8sCostPerCPUHigh
expr: sum(kubecost_cluster_cost_total) / sum(kubecost_cluster_cpu_usage_cores) > 5
for: 10m
labels:
severity: warning
annotations:
summary: "K8s cost per CPU too high"
description: "K8s cost per CPU usage is above $5. Check for resource over-provisioning or underutilization."

- alert: K8sCostAnomaly
expr: increase(kubecost_cluster_cost_total[1d]) > 1.2 * avg_over_time(increase(kubecost_cluster_cost_total[1d])[7d:1d])
for: 10m
labels:
severity: critical
annotations:
summary: "K8s cost anomaly detected"
description: "Today's K8s spend is over 20% higher than the last 7-day daily average. Investigate recent changes."
Loading
Loading