forked from GithubBackups/healthchecks
Setup instructions for Prometheus.
This commit is contained in:
parent
3092eaf88d
commit
7a0f3421dd
@ -40,6 +40,19 @@ def site_root():
|
||||
return settings.SITE_ROOT
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def site_scheme():
|
||||
parts = settings.SITE_ROOT.split("://")
|
||||
assert parts[0] in ("http", "https")
|
||||
return parts[0]
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def site_hostname():
|
||||
parts = settings.SITE_ROOT.split("://")
|
||||
return parts[1]
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def site_version():
|
||||
return settings.VERSION
|
||||
|
@ -49,6 +49,7 @@ channel_urls = [
|
||||
path("add_matrix/", views.add_matrix, name="hc-add-matrix"),
|
||||
path("add_apprise/", views.add_apprise, name="hc-add-apprise"),
|
||||
path("add_msteams/", views.add_msteams, name="hc-add-msteams"),
|
||||
path("add_prometheus/", views.add_prometheus, name="hc-add-prometheus"),
|
||||
path("<uuid:code>/checks/", views.channel_checks, name="hc-channel-checks"),
|
||||
path("<uuid:code>/name/", views.update_channel_name, name="hc-channel-name"),
|
||||
path("<uuid:code>/test/", views.send_test_notification, name="hc-channel-test"),
|
||||
@ -70,11 +71,8 @@ urlpatterns = [
|
||||
path("projects/<uuid:code>/checks/add/", views.add_check, name="hc-add-check"),
|
||||
path("checks/cron_preview/", views.cron_preview),
|
||||
path("projects/<uuid:code>/checks/status/", views.status, name="hc-status"),
|
||||
path(
|
||||
"projects/<uuid:code>/checks/metrics/<slug:key>",
|
||||
views.metrics,
|
||||
name="hc-metrics",
|
||||
),
|
||||
path("projects/<uuid:code>/checks/metrics/<slug:key>", views.metrics,),
|
||||
path("projects/<uuid:code>/metrics/<slug:key>", views.metrics, name="hc-metrics",),
|
||||
path("checks/<uuid:code>/", include(check_urls)),
|
||||
path("integrations/", include(channel_urls)),
|
||||
path("docs/", views.serve_doc, name="hc-docs"),
|
||||
|
@ -1542,6 +1542,12 @@ def add_msteams(request):
|
||||
return render(request, "integrations/add_msteams.html", ctx)
|
||||
|
||||
|
||||
@login_required
|
||||
def add_prometheus(request):
|
||||
ctx = {"page": "channels", "project": request.project}
|
||||
return render(request, "integrations/add_prometheus.html", ctx)
|
||||
|
||||
|
||||
def metrics(request, code, key):
|
||||
if len(key) != 32:
|
||||
return HttpResponseBadRequest()
|
||||
|
BIN
static/img/integrations/prometheus.png
Normal file
BIN
static/img/integrations/prometheus.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
BIN
static/img/integrations/setup_prometheus_1.png
Normal file
BIN
static/img/integrations/setup_prometheus_1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 39 KiB |
@ -291,6 +291,16 @@
|
||||
<a href="{% url 'hc-add-pagertree' %}" class="btn btn-primary">Add Integration</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<img src="{% static 'img/integrations/prometheus.png' %}"
|
||||
class="icon" alt="Prometheus icon" />
|
||||
|
||||
<h2>Prometheus</h2>
|
||||
<p>Export check and tag status values to Prometheus.</p>
|
||||
|
||||
<a href="{% url 'hc-add-prometheus' %}" class="btn btn-primary">Add Integration</a>
|
||||
</li>
|
||||
|
||||
{% if enable_pushbullet %}
|
||||
<li>
|
||||
<img src="{% static 'img/integrations/pushbullet.png' %}"
|
||||
|
72
templates/integrations/add_prometheus.html
Normal file
72
templates/integrations/add_prometheus.html
Normal file
@ -0,0 +1,72 @@
|
||||
{% extends "base.html" %}
|
||||
{% load humanize static hc_extras %}
|
||||
|
||||
{% block title %}Add Prometheus - {% site_name %}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<h1>Prometheus</h1>
|
||||
|
||||
<p>
|
||||
{% site_name %} provides a
|
||||
<a href="https://prometheus.io">Prometheus</a>-compatible metrics endpoint
|
||||
for each project. The endpoints are secured using each project's
|
||||
read-only API key.
|
||||
|
||||
If your team uses Prometheus, you can configure it to scrape {% site_name %}
|
||||
and have up-to-date check and tag status values available in Prometheus.
|
||||
</p>
|
||||
|
||||
<h2>Setup Guide</h2>
|
||||
|
||||
<div class="row ai-step">
|
||||
<div class="col-sm-6">
|
||||
<span class="step-no">1</span>
|
||||
<p>
|
||||
Look up your project's read-only API key in
|
||||
<strong>Project Settings › API Access</strong>.
|
||||
</p>
|
||||
<p>
|
||||
If you have not generated API keys before, you will need to do that
|
||||
first.
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<img
|
||||
class="ai-guide-screenshot"
|
||||
alt="Click create integration button"
|
||||
src="{% static 'img/integrations/setup_prometheus_1.png' %}" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row ai-step">
|
||||
<div class="col-sm-12">
|
||||
<span class="step-no">2</span>
|
||||
<p>
|
||||
Edit Prometheus configuration and add a new section in the
|
||||
<code>scrape_configs</code> section.
|
||||
</p>
|
||||
<pre>
|
||||
- job_name: 'healthchecks-{{ project|slugify }}'
|
||||
scheme: {% site_scheme %}
|
||||
metrics_path: /projects/{{ project.code }}/metrics/<strong>YOUR-READ-ONLY-API-KEY</strong>
|
||||
static_configs:
|
||||
- targets: ['{% site_hostname %}']</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row ai-step">
|
||||
<div class="col-sm-6">
|
||||
<span class="step-no">3</span>
|
||||
<p>
|
||||
Reload Prometheus' configuration. You should now start seeing
|
||||
{% site_name %} data appear in Prometheus.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user