Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Commit

Permalink
Support Prometheus in for dashboard topology (#1195)
Browse files Browse the repository at this point in the history
* [Support] change tidb-ansible script in tidb-ansible.

Signed-off-by: mapleFU <1506118561@qq.com>

* [ADD] Adding supports in roles.

Signed-off-by: mapleFU <1506118561@qq.com>

* [Multiple] pass the first when there is multiple arguments.
  • Loading branch information
liubo0127 authored Mar 5, 2020
1 parent d321508 commit 2286096
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 11 additions & 0 deletions roles/dashboard_topo/templates/init_dashboard_topo.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,23 @@ set -e
{% set alertmanager_path = hostvars[host].deploy_dir -%}
{% set _ = all_alertmanager.append("%s:%s%s" % (alertmanager_ip, alertmanager_port, alertmanager_path)) -%}
{% endfor -%}
{% set all_prometheus = [] -%}
{% set prometheus_hosts = groups.monitoring_servers %}
{% for host in prometheus_hosts -%}
{% set prometheus_ip = hostvars[host].ansible_host | default(hostvars[host].inventory_hostname) -%}
{% set prometheus_port = hostvars[host].prometheus_port -%}
{% set prometheus_path = hostvars[host].deploy_dir -%}
{% set _ = all_prometheus.append("%s:%s%s" % (prometheus_ip, prometheus_port, prometheus_path)) -%}
{% endfor -%}
{% set flag = "" %}
{% if all_grafana -%}
{% set flag = flag + " --grafana " + ','.join(all_grafana) -%}
{% endif -%}
{% if all_alertmanager -%}
{% set flag = flag + " --alertmanager " + ','.join(all_alertmanager) -%}
{% endif -%}
{% if all_prometheus %}
{% set flag = flag + " --prometheus " + ','.join(all_prometheus) -%}
{% endif -%}

python2 dashboard_topo.py --pd {{ all_pd | join(',') }} {{ flag }}
11 changes: 5 additions & 6 deletions scripts/dashboard_topo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import json
import argparse

ComponentToRegister = ('alertmanager', 'grafana', 'pd')
ComponentToRegister = ('alertmanager', 'grafana', 'pd', 'prometheus')


def parse_opts():
Expand Down Expand Up @@ -65,6 +65,8 @@ def request_topo(comp, topo, etcd_target):
if topo is None:
# if topo is None, do nothing
return
if ',' in topo:
topo = topo.split(',')[0]
ip, add = parse_address(topo)
ip, port = ip.split(':')

Expand Down Expand Up @@ -93,20 +95,17 @@ def concat_to_address(ip, port):
args = parse_opts()

# parse from args
# pd_address = concat_to_address(args.pd_host, args.pd_port)
# tidb_address = concat_to_address(args.tidb_host, args.tidb_port)
# alertmanager_address = concat_to_address(args.alertmanager_host,
# args.alertmanager_port)
# grafana_address = concat_to_address(args.grafana_host, args.grafana_port)
pd_address = args.pd
pd_address_zero, _ = parse_address(pd_address.split(',')[0])

alertmanager_address = args.alertmanager
grafana_address = args.grafana
prometheus_address = args.prometheus

mapping = {
'alertmanager': alertmanager_address,
'grafana': grafana_address,
'prometheus': prometheus_address,
}

for comp in ComponentToRegister:
Expand Down

0 comments on commit 2286096

Please sign in to comment.