Skip to content

Commit

Permalink
Telegraf graphite (#375)
Browse files Browse the repository at this point in the history
Telegraf graphite

graphite output

Reviewed-by: Anton Kachurin <[email protected]>
Reviewed-by: Polina Gubina <None>
Reviewed-by: Irina Pereiaslavskaia <None>
Reviewed-by: None <None>
  • Loading branch information
anton-sidelnikov authored Mar 26, 2021
1 parent 2f6e50a commit ebc607c
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 1 deletion.
2 changes: 2 additions & 0 deletions inventory/prod/group_vars/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ kms_key: csm_kms_key
ansible_ssh_user: linux
ansible_ssh_private_key_file: "{{ local_private_key }}"
container_name: "csm"
telegraf_graphite_url: localhost:2003
telegraf_graphite_env: production_eu-de
24 changes: 24 additions & 0 deletions playbooks/lb_monitoring_setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,30 @@
wait_for_connection:
timeout: 250

- name: Install telegraf client on nodes
hosts: gatewayed
become: yes
roles:
- role: telegraf_client
vars:
telegraf_graphite: true
telegraf_graphite_urls:
- "{{ telegraf_graphite_url }}"
telegraf_graphite_prefix: "stats.system.csm.{{ telegraf_graphite_env }}"
telegraf_graphite_template: host.tags.measurement.field
telegraf_plugins_base:
- name: cpu
options:
percpu: "false"
totalcpu: "true"
fielddrop:
- "time_*"
- name: net
options:
interfaces:
- "lo"
- "ens3"

- name: Setup nginx for TCP, HTTP, HTTPS connections
hosts: gatewayed
become: yes
Expand Down
14 changes: 13 additions & 1 deletion roles/telegraf_client/defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,30 @@ telegraf_hostname:
telegraf_omit_hostname: "false"
telegraf_install_url:

telegraf_influxdb: false
telegraf_influxdb_urls: []
telegraf_influxdb_database: telegraf
telegraf_influxdb_precision: s
telegraf_influxdb_retention_policy: autogen
telegraf_influxdb_write_consistency: any

telegraf_influxdb_timeout: 5s
telegraf_influxdb_username:
telegraf_influxdb_password:
telegraf_influxdb_user_agent:
telegraf_influxdb_udp_payload:

telegraf_graphite: false
telegraf_graphite_urls: []
telegraf_graphite_prefix:
telegraf_graphite_template:
telegraf_graphite_templates:
telegraf_graphite_tag_support:
telegraf_graphite_separator: "."
telegraf_graphite_tls_ca:
telegraf_graphite_tls_cert:
telegraf_graphite_tls_key:
telegraf_graphite_insecure_skip_verify:

telegraf_plugins_base:
- name: mem
- name: cpu
Expand Down
69 changes: 69 additions & 0 deletions roles/telegraf_client/templates/telegraf.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
###############################################################################

[outputs]
{% if telegraf_influxdb == true %}
[[outputs.influxdb]]
urls = [ "{{ telegraf_influxdb_urls|join('","') }}" ] # required
database = "{{ telegraf_influxdb_database }}" # required
Expand All @@ -49,7 +50,75 @@
{% if telegraf_influxdb_udp_payload is defined and telegraf_influxdb_udp_payload != None %}
udp_payload = {{ telegraf_influxdb_udp_payload }}
{% endif %}
{% endif %}

{% if telegraf_graphite == true %}
[[outputs.graphite]]
# TCP endpoint for your graphite instance.
# If multiple endpoints are configured, the output will be load balanced.
# Only one of the endpoints will be written to with each iteration.
servers = [ "{{ telegraf_graphite_urls|join('","') }}" ]

# Prefix metrics name
{% if telegraf_graphite_prefix is defined and telegraf_graphite_prefix != None %}
prefix = "{{ telegraf_graphite_prefix }}"
{% else %}
prefix = ""
{% endif %}

# Graphite output template
# see https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md
{% if telegraf_graphite_template is defined and telegraf_graphite_template != None %}
template = "{{ telegraf_graphite_template }}"
{% else %}
template = "host.tags.measurement.field"
{% endif %}

# Graphite templates patterns
# 1. Template for cpu
# 2. Template for disk*
# 3. Template for net
# 4. Default template
{% if telegraf_graphite_templates is defined and telegraf_graphite_templates != None %}
templates = "{{ telegraf_graphite_templates }}"
{% else %}
templates = [
"cpu host.measurement.field",
"disk* host.measurement.tags.field",
"net host.measurement.tags.field",
"mem host.tags.measurement.field",
"host.tags.measurement.field"
]
{% endif %}

# Enable Graphite tags support
{% if telegraf_graphite_tag_support is defined and telegraf_graphite_tag_support != None %}
template = "{{ telegraf_graphite_tag_support }}"
{% else %}
graphite_tag_support = false
{% endif %}

# Character for separating metric name and field for Graphite tags
graphite_separator = "{{ telegraf_graphite_separator }}"

# timeout in seconds for the write connection to graphite
timeout = 5

# Optional TLS Config
{% if telegraf_graphite_tls_ca is defined and telegraf_graphite_tls_ca != None %}
tls_ca = "{{ telegraf_graphite_tls_ca }}"
{% endif %}
{% if telegraf_graphite_tls_cert is defined and telegraf_graphite_tls_cert != None %}
tls_cert = "{{ telegraf_graphite_tls_cert }}"
{% endif %}
{% if telegraf_graphite_tls_key is defined and telegraf_graphite_tls_key != None %}
tls_key = "{{ telegraf_graphite_tls_key }}"
{% endif %}
# Use TLS but skip chain & host verification
{% if telegraf_graphite_insecure_skip_verify is defined and telegraf_graphite_insecure_skip_verify != None %}
insecure_skip_verify = "{{ telegraf_graphite_insecure_skip_verify }}"
{% endif %}
{% endif %}
###############################################################################
# PLUGINS #
###############################################################################
Expand Down

0 comments on commit ebc607c

Please sign in to comment.