update
This commit is contained in:
@@ -40,6 +40,7 @@ datasaker_docker_agents: ['dsk-docker-node-agent']
|
||||
|
||||
datasaker_docker_config_path: "~/.datasaker"
|
||||
datasaker_docker_global_config: "{{ datasaker_docker_config_path }}/config.yml"
|
||||
docker_default_path: "/var/lib/docker/containers/"
|
||||
|
||||
datasaker_docker_path: "/var/datasaker"
|
||||
datasaker_docker_user: "datasaker"
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
command: "-global.config=/etc/datasaker/global-config.yml -agent.config=/etc/datasaker/dsk-log-agent/agent-config.yml -mount.volume=true"
|
||||
volumes:
|
||||
- "{{ datasaker_docker_path }}:/var/datasaker/"
|
||||
- "/var/lib/docker/containers/:/var/datasaker/log/:ro"
|
||||
- "{{ datasaker_docker_global_config }}:/etc/datasaker/global-config.yml:ro"
|
||||
- "{{ datasaker_docker_path }}/log-agent-config.yml:/etc/datasaker/dsk-log-agent/agent-config.yml:ro"
|
||||
- "{{ item }}"
|
||||
loop: "{{ custom_log_volume | default(['{{ docker_default_path }}:/var/log/sample/:ro']) }}"
|
||||
|
||||
@@ -1,2 +1,52 @@
|
||||
---
|
||||
- name: "Create datasaker local directory"
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: "{{datasaker_docker_user}}"
|
||||
group: "{{datasaker_docker_group}}"
|
||||
mode: '0755'
|
||||
with_items:
|
||||
- "{{ datasaker_docker_path }}/agent/dsk-postgres-agent"
|
||||
- "{{ datasaker_docker_path }}/agent/dsk-plan-postgres-agent"
|
||||
|
||||
- name: "Setting dsk-postgres-agent config"
|
||||
template:
|
||||
src: postgres-agent-config.yml.j2
|
||||
dest: "{{ datasaker_docker_path }}/dsk-postgres-config.yml"
|
||||
|
||||
- name: "Setting plan-dsk-postgres-agent config"
|
||||
template:
|
||||
src: plan-postgres-agent-config.yml.j2
|
||||
dest: "{{ datasaker_docker_path }}/dsk-plan-postgres-config.yml"
|
||||
|
||||
- name: "Run dsk-postgres-agent container"
|
||||
docker_container:
|
||||
name: dsk-postgres-agent
|
||||
image: datasaker/dsk-postgres-agent:rel0.1.2
|
||||
state: started
|
||||
restart_policy: always
|
||||
detach: true
|
||||
env:
|
||||
DKS_LOG_LEVEL: "info"
|
||||
DATA_SOURCE_USER: "{{ postgres_user_name | default('') }}"
|
||||
DATA_SOURCE_PASS: "{{ postgres_user_password | default('') }}"
|
||||
DATA_SOURCE_URI: "{{ postgres_database_address | default('') }}:{{ postgres_database_port | default('') }}?sslmode=disable"
|
||||
volumes:
|
||||
- "{{ datasaker_docker_path }}:/var/datasaker/"
|
||||
- "{{ datasaker_docker_global_config }}:/etc/datasaker/global-config.yml:ro"
|
||||
- "{{ datasaker_docker_path }}/dsk-postgres-config.yml:/etc/datasaker/dsk-postgres-agent/agent-config.yml:ro"
|
||||
|
||||
- name: "Run dsk-plan-postgres-agent container"
|
||||
docker_container:
|
||||
name: dsk-plan-postgres-agent
|
||||
image: datasaker/dsk-plan-postgres-agent:latest
|
||||
state: started
|
||||
restart_policy: always
|
||||
detach: true
|
||||
env:
|
||||
DKS_LOG_LEVEL: "info"
|
||||
volumes:
|
||||
- "{{ datasaker_docker_path }}:/var/datasaker/"
|
||||
- "{{ datasaker_docker_global_config }}:/etc/datasaker/global-config.yml:ro"
|
||||
- "{{ datasaker_docker_path }}/dsk-plan-postgres-config.yml:/etc/datasaker/dsk-plan-postgres-agent/agent-config.yml:ro"
|
||||
|
||||
15
tasks/dsk-postgres-agent.yml
Normal file
15
tasks/dsk-postgres-agent.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: "Make agent Directory"
|
||||
ansible.builtin.file:
|
||||
path: "/etc/datasaker/{{ item }}"
|
||||
state: directory
|
||||
recurse: yes
|
||||
owner: root
|
||||
group: root
|
||||
with_items:
|
||||
- "dsk-postgres-agent"
|
||||
|
||||
- name: "Setting dsk-postgres-agent config"
|
||||
template:
|
||||
src: postgres-agent-config.yml.j2
|
||||
dest: "/etc/datasaker/dsk-postgres-agent/agent-config.yml"
|
||||
@@ -65,3 +65,13 @@
|
||||
state: absent
|
||||
when: datasaker_clean == True
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "Remove datasaker_docker_directory"
|
||||
ansible.builtin.file:
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
when: datasaker_clean == True
|
||||
ignore_errors: yes
|
||||
with_items:
|
||||
- "{{ datasaker_docker_config_path }}"
|
||||
- "{{ datasaker_docker_path }}"
|
||||
|
||||
20
templates/docker-postgres-agent-config.yml.j2
Normal file
20
templates/docker-postgres-agent-config.yml.j2
Normal file
@@ -0,0 +1,20 @@
|
||||
agent:
|
||||
metadata:
|
||||
agent_name: "{{ docker_postgres_agent_name | default('dsk-postgres-agent') }}"
|
||||
option:
|
||||
exporter_config:
|
||||
command: "/etc/datasaker/target-exporter"
|
||||
port: 9187
|
||||
scrape_configs:
|
||||
- job_name: dsk-postgres-agent
|
||||
metrics_path: /metrics/short
|
||||
url: localhost:9187
|
||||
filtering_configs:
|
||||
rule: drop
|
||||
- job_name: dsk-postgres-agent-long
|
||||
scrape_interval: 60s
|
||||
scrape_timeout: 10s
|
||||
metrics_path: /metrics/long
|
||||
url: localhost:9187
|
||||
filtering_configs:
|
||||
rule: drop
|
||||
@@ -1,8 +1,6 @@
|
||||
agent:
|
||||
metadata:
|
||||
agent_name: "{{ log_agent_name | default('dsk-log-agent') }}"
|
||||
cluster_id: "{{ log_agent_cluster_id | default('unknown') }}"
|
||||
environment: "{{ log_agent_environment | default('etc') }}"
|
||||
collect:
|
||||
- paths:
|
||||
{% if paths is defined and paths | length > 0 %}
|
||||
@@ -10,7 +8,7 @@ agent:
|
||||
- "{{ path | default('') }}"
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
- /var/log/*/*.log
|
||||
- /var/log/sample/*/*.log
|
||||
{% endif %}
|
||||
{% if exclude_paths is defined and exclude_paths | length > 0 %}
|
||||
exclude_paths:
|
||||
@@ -23,13 +21,13 @@ agent:
|
||||
{% if keywords is defined and keywords | length > 0 %}
|
||||
keywords:
|
||||
{% for keyword in keywords %}
|
||||
- "{{ keyword | default('') }}"
|
||||
- "{{ keyword | default('ERROR') }}"
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
keywords: []
|
||||
{% endif %}
|
||||
tag: "{{ log_agent_tag | default('sample') }}"
|
||||
tag: "{{ log_agent_tag | default('Default') }}"
|
||||
service:
|
||||
name: "{{ log_agent_service_name | default('test') }}"
|
||||
name: "{{ log_agent_service_name | default('default') }}"
|
||||
category: "{{ log_agent_service_category | default('etc') }}"
|
||||
type: "{{ log_agent_service_type | default('etc') }}"
|
||||
@@ -1,37 +0,0 @@
|
||||
agent:
|
||||
metadata:
|
||||
agent_name: "{{ log_agent_name | default('dsk-log-agent') }}"
|
||||
cluster_id: "{{ log_agent_cluster_id | default('unknown') }}"
|
||||
environment: "{{ log_agent_environment | default('etc') }}"
|
||||
collect:
|
||||
- paths:
|
||||
{% if paths is defined and paths | length > 0 %}
|
||||
{% for path in paths %}
|
||||
- "{{ path | default('') }}"
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
- /var/log/*/*.log
|
||||
{% endif %}
|
||||
|
||||
{% if exclude_paths is defined and exclude_paths | length > 0 %}
|
||||
exclude_paths:
|
||||
{% for exclude_path in exclude_paths %}
|
||||
- "{{ exclude_path | default('') }}"
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
exclude_paths: []
|
||||
{% endif %}
|
||||
|
||||
{% if keywords is defined and keywords | length > 0 %}
|
||||
keywords:
|
||||
{% for keyword in keywords %}
|
||||
- "{{ keyword | default('') }}"
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
keywords: []
|
||||
{% endif %}
|
||||
tag: "{{ log_agent_tag | default('sample') }}"
|
||||
service:
|
||||
name: "{{ log_agent_service_name | default('test') }}"
|
||||
category: "{{ log_agent_service_category | default('etc') }}"
|
||||
type: "{{ log_agent_service_type | default('etc') }}"
|
||||
@@ -1,7 +1,6 @@
|
||||
agent:
|
||||
metadata:
|
||||
agent_name: "{{ plan_postgres_agent_name | default('dsk-plan-postgres-agent') }}"
|
||||
cluster_id: "{{ plan_postgres_agent_cluster_id | default('REPLACE_CLUSTER_ID') }}"
|
||||
data_source_name:
|
||||
user: "{{ plan_postgres_user_name | default('') }}"
|
||||
password: "{{ plan_postgres_user_password | default('') }}"
|
||||
|
||||
19
templates/postgres-agent-config.yml.j2
Normal file
19
templates/postgres-agent-config.yml.j2
Normal file
@@ -0,0 +1,19 @@
|
||||
agent:
|
||||
metadata:
|
||||
agent_name: "{{ postgres_agent_name | default('dsk-postgres-agent') }}"
|
||||
option:
|
||||
exporter_config:
|
||||
command: "/usr/bin/dsk-postgres-exporter"
|
||||
port: 19187
|
||||
args:
|
||||
- --extend.query-path=/etc/datasaker/dsk-postgres-agent/queries.yaml
|
||||
- --data-source-user="{{ postgres_user_name | default('') }}"
|
||||
- --data-source-pass="{{ postgres_user_password | default('') }}"
|
||||
- --data-source-uri="{{ postgres_database_address | default('') }}":"{{ postgres_database_port | default('') }}"
|
||||
scrape_interval: 15s
|
||||
scrape_timeout: 5s
|
||||
scrape_configs:
|
||||
- job_name: dsk-postgres-agent
|
||||
url: localhost:19187
|
||||
filtering_configs:
|
||||
rule: drop
|
||||
Reference in New Issue
Block a user