-
- Silence
-
+
+
-
-
-
-
diff --git a/promgen/templates/promgen/silence_row.html b/promgen/templates/promgen/silence_row.html
new file mode 100644
index 000000000..143ac3dff
--- /dev/null
+++ b/promgen/templates/promgen/silence_row.html
@@ -0,0 +1,16 @@
+{% verbatim %}
+
{{silence.endsAt}} |
+
+
+ |
+
{{silence.comment}} |
+
{{silence.createdBy}} |
+
+ Expire
+ |
+{% endverbatim %}
diff --git a/promgen/tests/test_silence.py b/promgen/tests/test_silence.py
index 339b80c06..58373fd5c 100644
--- a/promgen/tests/test_silence.py
+++ b/promgen/tests/test_silence.py
@@ -26,16 +26,20 @@ def setUp(self):
@override_settings(PROMGEN=TEST_SETTINGS)
@mock.patch('promgen.util.post')
def test_duration(self, mock_post):
+ mock_post.return_value.status_code = 200
+
with mock.patch('django.utils.timezone.now') as mock_now:
mock_now.return_value = datetime.datetime(2017, 12, 14, tzinfo=datetime.timezone.utc)
# I would prefer to be able to test with multiple labels, but since
# it's difficult to test a list of dictionaries (the order is non-
# deterministic) we just test with a single label for now
- self.client.post(reverse('silence'),
+ self.client.post(
+ reverse('proxy-silence'),
data={
'duration': '1m',
- 'label.instance': 'example.com:[0-9]*'
+ "labels": {"instance": "example.com:[0-9]*"},
},
+ content_type="application/json",
)
mock_post.assert_called_with(
'http://alertmanager:9093/api/v1/silences',
@@ -45,14 +49,18 @@ def test_duration(self, mock_post):
@override_settings(PROMGEN=TEST_SETTINGS)
@mock.patch('promgen.util.post')
def test_range(self, mock_post):
+ mock_post.return_value.status_code = 200
+
with mock.patch('django.utils.timezone.now') as mock_now:
mock_now.return_value = datetime.datetime(2017, 12, 14, tzinfo=datetime.timezone.utc)
- self.client.post(reverse('silence'),
+ self.client.post(
+ reverse('proxy-silence'),
data={
- 'start': '2017-12-14 00:01',
- 'stop': '2017-12-14 00:05',
- 'label.instance': 'example.com:[0-9]*'
+ 'startsAt': '2017-12-14 00:01',
+ 'endsAt': '2017-12-14 00:05',
+ "labels": {"instance": "example.com:[0-9]*"},
},
+ content_type="application/json",
)
mock_post.assert_called_with(
'http://alertmanager:9093/api/v1/silences',
diff --git a/promgen/urls.py b/promgen/urls.py
index 5d86f0727..df572f370 100644
--- a/promgen/urls.py
+++ b/promgen/urls.py
@@ -90,17 +90,11 @@
url(r'^status/$', views.Status.as_view(), name='status'),
url(r'^import/$', views.Import.as_view(), name='import'),
- url(r'^silence$', views.Silence.as_view(), name='silence'),
- url(r'^silence/expire$', views.SilenceExpire.as_view(), name='silence-expire'),
-
url(r'^search/$', views.Search.as_view(), name='search'),
url(r'^metrics$', csrf_exempt(views.Metrics.as_view()), name='metrics'),
url(r'^commit$', csrf_exempt(views.Commit.as_view()), name='commit'),
- url(r'^ajax/silence$', csrf_exempt(views.AjaxSilence.as_view()), name='ajax-silence'),
- url(r'^ajax/alert$', csrf_exempt(views.AjaxAlert.as_view()), name='ajax-alert'),
-
url('', include('django.contrib.auth.urls')),
url('', include('social_django.urls', namespace='social')),
@@ -111,18 +105,26 @@
url(r'^api/v1/config', csrf_exempt(views.ApiConfig.as_view())),
# Promgen API
- url(r'^api/v1/targets', csrf_exempt(views.ApiConfig.as_view()), name='config-targets'),
- url(r'^api/v1/rules', csrf_exempt(views.RulesConfig.as_view()), name='config-rules'),
- url(r'^api/v1/urls', csrf_exempt(views.URLConfig.as_view()), name='config-urls'),
- url(r'^api/v1/alerts', csrf_exempt(views.Alert.as_view()), name='alert'),
- url(r'^api/v1/host/(?P
\S+)', views.HostDetail.as_view()),
+ path('api/v1/targets', csrf_exempt(views.ApiConfig.as_view()), name='config-targets'),
+ path('api/v1/rules', csrf_exempt(views.RulesConfig.as_view()), name='config-rules'),
+ path('api/v1/urls', csrf_exempt(views.URLConfig.as_view()), name='config-urls'),
+ path('api/v1/alerts', csrf_exempt(views.Alert.as_view()), name='alert'),
+ path('api/v1/host/', views.HostDetail.as_view()),
# Prometheus Proxy
+ # these apis need to match the same path because Promgen can pretend to be a Prometheus API
path("graph", proxy.ProxyGraph.as_view()),
path("api/v1/label/