Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuleTest should test against all connected Prometheus instances to reduce confusion #90

Merged
merged 1 commit into from
Jul 13, 2018
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 promgen/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
url(r'^graph', views.ProxyGraph.as_view()),
url(r'^api/v1/label/(.+)/values', views.ProxyLabel.as_view(), name='proxy-label'),
url(r'^api/v1/query_range', views.ProxyQueryRange.as_view()),
url(r'^api/v1/query', views.ProxyQuery.as_view()),
url(r'^api/v1/query', views.ProxyQuery.as_view(), name='proxy-query'),
url(r'^api/v1/series', views.ProxySeries.as_view()),
]

Expand Down
15 changes: 4 additions & 11 deletions promgen/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import promgen.templatetags.promgen as macro
from promgen import (celery, discovery, forms, models, plugins, prometheus,
signals, util, version)
from promgen.shortcuts import resolve_domain

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -1168,17 +1169,9 @@ def post(self, request, pk):
rule = get_object_or_404(models.Rule, id=pk)

query = macro.rulemacro(request.POST['query'], rule)

# TODO: Refactor out similar to ProxyQueryRange
# This is the only place where we currently have to deal with getting a
# url based on the rule type but we want to remove this special case
# soon
if rule.content_type.model == 'service':
url = '{}/api/v1/query'.format(rule.content_object.shard.url)
if rule.content_type.model == 'project':
url = '{}/api/v1/query'.format(rule.content_object.service.shard.url)
if rule.content_type.model == 'site':
url = '{}/api/v1/query'.format(models.Shard.objects.first().url)
# Since our rules affect all servers we use Promgen's proxy-query to test our rule
# against all the servers at once
url = resolve_domain('proxy-query')

logger.debug('Querying %s with %s', url, query)
start = time.time()
Expand Down