Add telegraf to ansible
This commit is contained in:
		
							parent
							
								
									565509a5a9
								
							
						
					
					
						commit
						90064091ea
					
				
					 8 changed files with 81 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -8,6 +8,7 @@
 | 
			
		|||
    - forgejo-runner
 | 
			
		||||
    - homebox
 | 
			
		||||
    - influxdb
 | 
			
		||||
    - telegraf
 | 
			
		||||
    - umami
 | 
			
		||||
    - uptime-kuma
 | 
			
		||||
    - watchtower
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -62,7 +62,7 @@ svc_env:
 | 
			
		|||
  FORGEJO__oauth2__JWT_SECRET: "{{ vault_forgejo. oauth2_jwt_secret}}"
 | 
			
		||||
 | 
			
		||||
  FORGEJO__metrics__ENABLED: true
 | 
			
		||||
  FORGEJO__metrics__TOKEN: "{{ vault_forgejo.metrics_token }}"
 | 
			
		||||
  FORGEJO__metrics__TOKEN: "{{ vault_metrics_token }}"
 | 
			
		||||
 | 
			
		||||
  FORGEJO__actions__ENABLED: true
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -63,7 +63,7 @@ svc_yml:
 | 
			
		|||
 | 
			
		||||
compose:
 | 
			
		||||
  watchtower: false
 | 
			
		||||
  image: influxdb
 | 
			
		||||
  image: influxdb:2
 | 
			
		||||
  volumes:
 | 
			
		||||
    - ./influxdb.yml:/etc/influxdb2/config.yml
 | 
			
		||||
    - data:{{ svc.data_dir }}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										16
									
								
								_ansible/roles/telegraf/tasks/main.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								_ansible/roles/telegraf/tasks/main.yml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,16 @@
 | 
			
		|||
---
 | 
			
		||||
- name: Deploy {{ svc.name }}
 | 
			
		||||
  tags:
 | 
			
		||||
    - telegraf
 | 
			
		||||
    - monitoring
 | 
			
		||||
  block:
 | 
			
		||||
    - import_tasks: steps/create-service-directory.yml
 | 
			
		||||
    - import_tasks: steps/template-docker-compose.yml
 | 
			
		||||
 | 
			
		||||
    - name: Template config
 | 
			
		||||
      ansible.builtin.template:
 | 
			
		||||
        src: telegraf.conf.j2
 | 
			
		||||
        dest: "{{ (service_path, 'telegraf.conf') | path_join }}"
 | 
			
		||||
        mode: "0664"
 | 
			
		||||
 | 
			
		||||
    - import_tasks: steps/start-service.yml
 | 
			
		||||
							
								
								
									
										32
									
								
								_ansible/roles/telegraf/templates/telegraf.conf.j2
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								_ansible/roles/telegraf/templates/telegraf.conf.j2
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,32 @@
 | 
			
		|||
[agent]
 | 
			
		||||
  interval = "60s"
 | 
			
		||||
  round_interval = true
 | 
			
		||||
  metric_batch_size = 1000
 | 
			
		||||
  metric_buffer_limit = 10000
 | 
			
		||||
  collection_jitter = "0s"
 | 
			
		||||
  flush_interval = "10s"
 | 
			
		||||
  flush_jitter = "0s"
 | 
			
		||||
  precision = ""
 | 
			
		||||
  hostname = "node002.serguzim.me"
 | 
			
		||||
  omit_hostname = false
 | 
			
		||||
 | 
			
		||||
[[outputs.influxdb_v2]]
 | 
			
		||||
  urls = ["{{ svc.influxdb.url }}"]
 | 
			
		||||
  token = "{{ svc.influxdb.token }}"
 | 
			
		||||
  organization = "{{ svc.influxdb.organization }}"
 | 
			
		||||
  bucket = "{{ svc.influxdb.bucket }}"
 | 
			
		||||
 | 
			
		||||
[[inputs.prometheus]]
 | 
			
		||||
  urls = [
 | 
			
		||||
    {%- for url in svc.prometheus.urls -%}
 | 
			
		||||
		"{{ url }}",
 | 
			
		||||
	{%- endfor -%}
 | 
			
		||||
  ]
 | 
			
		||||
 | 
			
		||||
  bearer_token_string = "{{ svc.prometheus.bearer_token }}"
 | 
			
		||||
 | 
			
		||||
[[inputs.postgresql]]
 | 
			
		||||
  address = "postgres://{{ svc.postgresql.user }}:{{ svc.postgresql.pass }}@{{ svc.postgresql.host }}:{{ svc.postgresql.port }}/{{ svc.postgresql.database }}?sslmode=verify-full"
 | 
			
		||||
  ignored_databases = ["postgres", "template0", "template1"]
 | 
			
		||||
  prepared_statements = true
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										28
									
								
								_ansible/roles/telegraf/vars/main.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								_ansible/roles/telegraf/vars/main.yml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,28 @@
 | 
			
		|||
svc:
 | 
			
		||||
  name: telegraf
 | 
			
		||||
  influxdb:
 | 
			
		||||
    url: "https://tick.serguzim.me"
 | 
			
		||||
    token: "{{ vault_telegraf.influxdb_token }}"
 | 
			
		||||
    organization: serguzim.net
 | 
			
		||||
    bucket: metrics
 | 
			
		||||
  prometheus:
 | 
			
		||||
    urls:
 | 
			
		||||
      - https://git.serguzim.me/metrics
 | 
			
		||||
      - https://matrix.msrg.cc/_synapse/metrics
 | 
			
		||||
      - https://tick.serguzim.me/metrics
 | 
			
		||||
    bearer_token: "{{ vault_metrics_token }}"
 | 
			
		||||
  postgresql:
 | 
			
		||||
    user: "{{ vault_telegraf.db.user }}"
 | 
			
		||||
    pass: "{{ vault_telegraf.db.pass }}"
 | 
			
		||||
    host: "{{ postgres.host }}"
 | 
			
		||||
    port: "{{ postgres.port }}"
 | 
			
		||||
    database: "telegraf"
 | 
			
		||||
 | 
			
		||||
compose:
 | 
			
		||||
  watchtower: false
 | 
			
		||||
  image: telegraf:1.28
 | 
			
		||||
  volumes:
 | 
			
		||||
    - ./telegraf.conf:/etc/telegraf/telegraf.conf:ro
 | 
			
		||||
  file:
 | 
			
		||||
    volumes:
 | 
			
		||||
      data:
 | 
			
		||||
		Reference in a new issue