redo prometheus scrapers and build the jobs for them in prometheus.yml

This commit is contained in:
Jonathan Math 2021-04-30 13:48:48 -05:00
parent 0de1c8ecfc
commit 9cbad888c7
19 changed files with 358 additions and 25 deletions

View file

@ -9,8 +9,14 @@ class AppServers(View):
data = dict((("%s" % s['_id'].replace('-', ''), s['feeds']) for s in self.stats)) data = dict((("%s" % s['_id'].replace('-', ''), s['feeds']) for s in self.stats))
if self.total: if self.total:
data['total'] = self.total[0]['feeds'] data['total'] = self.total[0]['feeds']
chart_name = "app_servers"
return render(request, 'monitor/prometheus_data.html', {"data": data}) chart_type = "histogram"
context = {
"data": data,
"chart_name": chart_name,
"chart_type": chart_type,
}
return render(request, 'monitor/prometheus_data.html', context)
@property @property
def stats(self): def stats(self):

View file

@ -8,7 +8,15 @@ class AppTimes(View):
def get(self, request): def get(self, request):
servers = dict((("%s" % s['_id'], s['page_load']) for s in self.stats)) servers = dict((("%s" % s['_id'], s['page_load']) for s in self.stats))
data = servers data = servers
return render(request, 'monitor/prometheus_data.html', {"data": data}) chart_name = "app_times"
chart_type = "histogram"
context = {
"data": data,
"chart_name": chart_name,
"chart_type": chart_type,
}
return render(request, 'monitor/prometheus_data.html', context)
@property @property
def stats(self): def stats(self):

View file

@ -13,5 +13,13 @@ class Classifiers(View):
'titles': MClassifierTitle.objects.count(), 'titles': MClassifierTitle.objects.count(),
} }
return render(request, 'monitor/prometheus_data.html', {"data": data}) chart_name = "classifiers"
chart_type = "histogram"
context = {
"data": data,
"chart_name": chart_name,
"chart_type": chart_type,
}
return render(request, 'monitor/prometheus_data.html', context)

View file

@ -16,5 +16,12 @@ class DbTimes(View):
'task_mongo_avg': MStatistics.get('latest_task_mongo_avg'), 'task_mongo_avg': MStatistics.get('latest_task_mongo_avg'),
'task_redis_avg': MStatistics.get('latest_task_redis_avg'), 'task_redis_avg': MStatistics.get('latest_task_redis_avg'),
} }
chart_name = "db_times"
chart_type = "histogram"
return render(request, 'monitor/prometheus_data.html', {"data": data}) context = {
"data": data,
"chart_name": chart_name,
"chart_type": chart_type,
}
return render(request, 'monitor/prometheus_data.html', context)

View file

@ -10,5 +10,13 @@ class Errors(View):
data = { data = {
'feed_success': statistics['feeds_fetched'], 'feed_success': statistics['feeds_fetched'],
} }
return render(request, 'monitor/prometheus_data.html', {"data": data}) chart_name = "errors"
chart_type = "histogram"
context = {
"data": data,
"chart_name": chart_name,
"chart_type": chart_type,
}
return render(request, 'monitor/prometheus_data.html', context)

View file

@ -45,6 +45,14 @@ class FeedCounts(View):
'active_feeds': active_feeds, 'active_feeds': active_feeds,
'push_feeds': push_feeds, 'push_feeds': push_feeds,
} }
return render(request, 'monitor/prometheus_data.html', {"data": data}) chart_name = "feed_counts"
chart_type = "histogram"
context = {
"data": data,
"chart_name": chart_name,
"chart_type": chart_type,
}
return render(request, 'monitor/prometheus_data.html', context)

View file

@ -26,6 +26,14 @@ class Feeds(View):
'profiles': MSocialProfile.objects.count(), 'profiles': MSocialProfile.objects.count(),
'social_subscriptions': MSocialSubscription.objects.count(), 'social_subscriptions': MSocialSubscription.objects.count(),
} }
chart_name = "feeds"
chart_type = "histogram"
return render(request, 'monitor/prometheus_data.html', {"data": data}) context = {
"data": data,
"chart_name": chart_name,
"chart_type": chart_type,
}
return render(request, 'monitor/prometheus_data.html', context)

View file

@ -10,5 +10,13 @@ class LoadTimes(View):
'feed_loadtimes_avg_hour': MStatistics.get('latest_avg_time_taken'), 'feed_loadtimes_avg_hour': MStatistics.get('latest_avg_time_taken'),
'feeds_loaded_hour': MStatistics.get('latest_sites_loaded'), 'feeds_loaded_hour': MStatistics.get('latest_sites_loaded'),
} }
return render(request, 'monitor/prometheus_data.html', {"data": data}) chart_name = "load_times"
chart_type = "histogram"
context = {
"data": data,
"chart_name": chart_name,
"chart_type": chart_type,
}
return render(request, 'monitor/prometheus_data.html', context)

View file

@ -10,5 +10,13 @@ class Stories(View):
'stories': MStory.objects.count(), 'stories': MStory.objects.count(),
'starred_stories': MStarredStory.objects.count(), 'starred_stories': MStarredStory.objects.count(),
} }
return render(request, 'monitor/prometheus_data.html', {"data": data}) chart_name = "stories"
chart_type = "histogram"
context = {
"data": data,
"chart_name": chart_name,
"chart_type": chart_type,
}
return render(request, 'monitor/prometheus_data.html', context)

View file

@ -7,8 +7,15 @@ class TasksCodes(View):
def get(self, request): def get(self, request):
data = dict((("_%s" % s['_id'], s['feeds']) for s in self.stats)) data = dict((("_%s" % s['_id'], s['feeds']) for s in self.stats))
chart_name = "task_codes"
return render(request, 'monitor/prometheus_data.html', {"data": data}) chart_type = "histogram"
context = {
"data": data,
"chart_name": chart_name,
"chart_type": chart_type,
}
return render(request, 'monitor/prometheus_data.html', context)
@property @property
def stats(self): def stats(self):

View file

@ -8,7 +8,15 @@ class TasksPipeline(View):
def get(self, request): def get(self, request):
data =self.stats data =self.stats
return render(request, 'monitor/prometheus_data.html', {"data": data}) chart_name = "task_pipeline"
chart_type = "histogram"
context = {
"data": data,
"chart_name": chart_name,
"chart_type": chart_type,
}
return render(request, 'monitor/prometheus_data.html', context)
@property @property
def stats(self): def stats(self):

View file

@ -10,8 +10,15 @@ class TasksServers(View):
data = dict((("%s" % s['_id'].replace('-', ''), s['feeds']) for s in self.stats)) data = dict((("%s" % s['_id'].replace('-', ''), s['feeds']) for s in self.stats))
if self.total: if self.total:
data['total'] = self.total[0]['feeds'] data['total'] = self.total[0]['feeds']
chart_name = "task_servers"
chart_type = "histogram"
return render(request, 'monitor/prometheus_data.html', {"data": data}) context = {
"data": data,
"chart_name": chart_name,
"chart_type": chart_type,
}
return render(request, 'monitor/prometheus_data.html', context)
@property @property

View file

@ -8,8 +8,15 @@ class TasksTimes(View):
def get(self, request): def get(self, request):
data = dict((("%s" % s['_id'], s['total']) for s in self.stats)) data = dict((("%s" % s['_id'], s['total']) for s in self.stats))
chart_name = "task_times"
chart_type = "histogram"
return render(request, 'monitor/prometheus_data.html', {"data": data}) context = {
"data": data,
"chart_name": chart_name,
"chart_type": chart_type,
}
return render(request, 'monitor/prometheus_data.html', context)
@property @property

View file

@ -20,5 +20,13 @@ class Updates(View):
'celery_work_queue': r.llen("work_queue"), 'celery_work_queue': r.llen("work_queue"),
'celery_search_queue': r.llen("search_indexer"), 'celery_search_queue': r.llen("search_indexer"),
} }
return render(request, 'monitor/prometheus_data.html', {"data": data}) chart_name = "updates"
chart_type = "histogram"
context = {
"data": data,
"chart_name": chart_name,
"chart_type": chart_type,
}
return render(request, 'monitor/prometheus_data.html', context)

View file

@ -19,5 +19,13 @@ class Users(View):
'premium': Profile.objects.filter(is_premium=True).count(), 'premium': Profile.objects.filter(is_premium=True).count(),
'queued': RNewUserQueue.user_count(), 'queued': RNewUserQueue.user_count(),
} }
return render(request, 'monitor/prometheus_data.html', {"data": data}) chart_name = "users"
chart_type = "histogram"
context = {
"data": data,
"chart_name": chart_name,
"chart_type": chart_type,
}
return render(request, 'monitor/prometheus_data.html', context)

View file

@ -110,7 +110,7 @@ services:
- 9200:9200 - 9200:9200
- 9300:9300 - 9300:9300
volumes: volumes:
- ./docker/volumes/elasticsearch:/usr/share/elasticsearch/data - ./docker/volumes/elasticsearch:/elasticsearch/dat
- ./config/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml - ./config/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
db_mongo: db_mongo:
@ -163,13 +163,18 @@ services:
- ./docker/volumes/prometheus_data:/prometheus - ./docker/volumes/prometheus_data:/prometheus
depends_on: depends_on:
- node-exporter - node-exporter
- haproxy
external_links:
- haproxy
node-exporter: node-exporter:
container_name: node-exporter
image: prom/node-exporter image: prom/node-exporter
ports: ports:
- 9100:9100 - 9100:9100
grafana: grafana:
container_name: grafana
image: grafana/grafana image: grafana/grafana
environment: environment:
- GF_SECURITY_ADMIN_PASSWORD=pass - GF_SECURITY_ADMIN_PASSWORD=pass

View file

@ -3,9 +3,115 @@ global:
external_labels: external_labels:
monitor: 'my-monitor' monitor: 'my-monitor'
scrape_configs: scrape_configs:
- job_name: 'prometheus' #- job_name: 'prometheus'
target_groups: # target_groups:
- targets: ['localhost:9090'] # - targets: ['localhost:9090']
- job_name: 'node-exporter' - job_name: 'node-exporter'
target_groups: target_groups:
- targets: ['node-exporter:9100'] - targets: ['node-exporter:9100']
- job_name: 'app_servers'
target_groups:
- targets: ['haproxy']
metrics_path: /monitor/app-servers
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'app_times'
target_groups:
- targets: ['haproxy']
metrics_path: /monitor/app-times
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'classifiers'
target_groups:
- targets: ['haproxy']
metrics_path: /monitor/classifiers
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'db_times'
target_groups:
- targets: ['haproxy']
metrics_path: /monitor/db-times
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'errors'
target_groups:
- targets: ['haproxy']
metrics_path: /monitor/errors
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'feed_counts'
target_groups:
- targets: ['haproxy']
metrics_path: /monitor/feed-counts
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'feeds'
target_groups:
- targets: ['haproxy']
metrics_path: /monitor/feeds
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'load_times'
target_groups:
- targets: ['haproxy']
metrics_path: /monitor/load-times
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'stories'
target_groups:
- targets: ['haproxy']
metrics_path: /monitor/stories
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'task_codes'
target_groups:
- targets: ['haproxy']
metrics_path: /monitor/task-codes
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'task_pipeline'
target_groups:
- targets: ['haproxy']
metrics_path: /monitor/task-pipeline
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'task_servers'
target_groups:
- targets: ['haproxy']
metrics_path: /monitor/task-servers
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'task_times'
target_groups:
- targets: ['haproxy']
metrics_path: /monitor/task-times
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'updates'
target_groups:
- targets: ['haproxy']
metrics_path: /monitor/updates
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'users'
target_groups:
- targets: ['haproxy']
metrics_path: /monitor/users
scheme: https
tls_config:
insecure_skip_verify: true

View file

@ -5,7 +5,114 @@ global:
scrape_configs: scrape_configs:
- job_name: 'prometheus' - job_name: 'prometheus'
target_groups: target_groups:
- targets: ['localhost:9090'] - targets: ['localhost:9090']
- job_name: 'node-exporter' - job_name: 'node-exporter'
target_groups: target_groups:
- targets: ['node-exporter:9100'] - targets: ['node-exporter:9100']
- job_name: 'app_servers'
target_groups:
- targets: ['{{ ansible_ssh_host }}']
metrics_path: /monitor/app-servers
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'app_times'
target_groups:
- targets: ['{{ ansible_ssh_host }}']
metrics_path: /monitor/app-times
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'classifiers'
target_groups:
- targets: ['{{ ansible_ssh_host }}']
metrics_path: /monitor/classifiers
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'db_times'
target_groups:
- targets: ['{{ ansible_ssh_host }}']
metrics_path: /monitor/db-times
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'errors'
target_groups:
- targets: ['{{ ansible_ssh_host }}']
metrics_path: /monitor/errors
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'feed_counts'
target_groups:
- targets: ['{{ ansible_ssh_host }}']
metrics_path: /monitor/feed-counts
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'feeds'
target_groups:
- targets: ['{{ ansible_ssh_host }}']
metrics_path: /monitor/feeds
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'load_times'
target_groups:
- targets: ['{{ ansible_ssh_host }}']
metrics_path: /monitor/load-times
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'stories'
target_groups:
- targets: ['{{ ansible_ssh_host }}']
metrics_path: /monitor/stories
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'task_codes'
target_groups:
- targets: ['{{ ansible_ssh_host }}']
metrics_path: /monitor/task-codes
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'task_pipeline'
target_groups:
- targets: ['{{ ansible_ssh_host }}']
metrics_path: /monitor/task-pipeline
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'task_servers'
target_groups:
- targets: ['{{ ansible_ssh_host }}']
metrics_path: /monitor/task-servers
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'task_times'
target_groups:
- targets: ['{{ ansible_ssh_host }}']
metrics_path: /monitor/task-times
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'updates'
target_groups:
- targets: ['{{ ansible_ssh_host }}']
metrics_path: /monitor/updates
scheme: https
tls_config:
insecure_skip_verify: true
- job_name: 'users'
target_groups:
- targets: ['{{ ansible_ssh_host }}']
metrics_path: /monitor/users
scheme: https
tls_config:
insecure_skip_verify: true

View file

@ -1,3 +1,4 @@
{% for k, v in data.items %} {% for k, v in data.items %}
{{ k }} {{ v }}<br> # TYPE {{chart_name}}_{{k}} {{chart_type}}
{{chart_name}}_{{k}} {{ v }}
{% endfor %} {% endfor %}