diff --git a/roles/myLimbo.docker.promtail/meta/main.yml b/roles/myLimbo.docker.promtail/meta/main.yml index 6f3ad80..242496d 100644 --- a/roles/myLimbo.docker.promtail/meta/main.yml +++ b/roles/myLimbo.docker.promtail/meta/main.yml @@ -3,7 +3,7 @@ galaxy_info: author: mf - description: promtail docker role + description: docker promtail role company: limbosolutions # If the issue tracker for your role is not on github, uncomment the @@ -50,4 +50,5 @@ galaxy_info: # NOTE: A tag is limited to a single word comprised of alphanumeric characters. # Maximum 20 tags per role. -dependencies: [] +#dependencies: +# - role: myInfra.docker diff --git a/roles/myLimbo.docker.telegraf/meta/main.yml b/roles/myLimbo.docker.telegraf/meta/main.yml new file mode 100644 index 0000000..c03511f --- /dev/null +++ b/roles/myLimbo.docker.telegraf/meta/main.yml @@ -0,0 +1,52 @@ + + + +galaxy_info: + author: mf + description: docker telegraf role + company: limbosolutions + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] diff --git a/roles/myLimbo.docker.telegraf/tasks/main.yml b/roles/myLimbo.docker.telegraf/tasks/main.yml new file mode 100644 index 0000000..d0f0cff --- /dev/null +++ b/roles/myLimbo.docker.telegraf/tasks/main.yml @@ -0,0 +1,184 @@ +--- +- name: Check folders + become: true + ansible.builtin.file: + path: "{{ config_file.host_path }}" + state: directory + mode: '0755' + + +- name: Setup config File + become: true + copy: + dest: "{{ config_file.host_path }}/telegraf.conf" + content: | + # file maintained by myInfra.docker.telegraf ansible role + + + [global_tags] + # dc = "us-east-1" # will tag all metrics with dc=us-east-1 + # rack = "1a" + ## Environment variables can be used as tags, and throughout the config file + # user = "$USER" + + + [agent] + hostname = "{{hostname}}" + omit_hostname = false + interval = "10s" + round_interval = true + metric_batch_size = 1000 + metric_buffer_limit = 10000 + collection_jitter = "0s" + flush_interval = "10s" + flush_jitter = "0s" + precision = "0s" + + + # Output Configuration for telegraf agent + [[outputs.influxdb_v2]] + # ## The URLs of the InfluxDB cluster nodes. + # ## + # ## Multiple URLs can be specified for a single cluster, only ONE of the + # ## urls will be written to each interval. + # ## ex: urls = ["https://us-west-2-1.aws.cloud2.influxdata.com"] + urls = ["{{influxdb2.url}}"] + + ## Token for authentication. + token = "{{influxdb2.token}}" + # + # ## Organization is the name of the organization you wish to write to. + organization = "{{ influxdb2.org }}" + # + # ## Destination bucket to write into. + bucket = "{{ influxdb2.bucket }}" + + [[inputs.docker]] + ## Docker Endpoint + ## To use TCP, set endpoint = "tcp://[ip]:[port]" + ## To use environment variables (ie, docker-machine), set endpoint = "ENV" + endpoint = "unix:///var/run/docker.sock" + + ## Set to true to collect Swarm metrics(desired_replicas, running_replicas) + ## Note: configure this in one of the manager nodes in a Swarm cluster. + ## configuring in multiple Swarm managers results in duplication of metrics. + gather_services = false + + ## Set the source tag for the metrics to the container ID hostname, eg first 12 chars + source_tag = false + + ## Containers to include and exclude. Collect all if empty. Globs accepted. + container_name_include = [] + container_name_exclude = [] + + ## Container states to include and exclude. Globs accepted. + ## When empty only containers in the "running" state will be captured. + ## example: container_state_include = ["created", "restarting", "running", "removing", "paused", "exited", "dead"] + ## example: container_state_exclude = ["created", "restarting", "running", "removing", "paused", "exited", "dead"] + # container_state_include = [] + # container_state_exclude = [] + + ## Objects to include for disk usage query + ## Allowed values are "container", "image", "volume" + ## When empty disk usage is excluded + storage_objects = [] + + ## Timeout for docker list, info, and stats commands + timeout = "5s" + + ## Specifies for which classes a per-device metric should be issued + ## Possible values are 'cpu' (cpu0, cpu1, ...), 'blkio' (8:0, 8:1, ...) and 'network' (eth0, eth1, ...) + # perdevice_include = ["cpu"] + + ## Specifies for which classes a total metric should be issued. Total is an aggregated of the 'perdevice_include' values. + ## Possible values are 'cpu', 'blkio' and 'network' + ## Total 'cpu' is reported directly by Docker daemon, and 'network' and 'blkio' totals are aggregated by this plugin. + # total_include = ["cpu", "blkio", "network"] + + ## docker labels to include and exclude as tags. Globs accepted. + ## Note that an empty array for both will include all labels as tags + docker_label_include = [] + docker_label_exclude = [] + + ## Which environment variables should we use as a tag + tag_env = ["JAVA_HOME", "HEAP_SIZE"] + + ## Optional TLS Config + # tls_ca = "/etc/telegraf/ca.pem" + # tls_cert = "/etc/telegraf/cert.pem" + # tls_key = "/etc/telegraf/key.pem" + ## Use TLS but skip chain & host verification + # insecure_skip_verify = false + # Read metrics about cpu usage + [[inputs.cpu]] + ## Whether to report per-cpu stats or not + percpu = true + ## Whether to report total system cpu stats or not + totalcpu = true + ## If true, collect raw CPU time metrics + collect_cpu_time = false + ## If true, compute and report the sum of all non-idle CPU states + report_active = false + + + # Read metrics about disk usage by mount point + [[inputs.disk]] + ## By default stats will be gathered for all mount points. + ## Set mount_points will restrict the stats to only the specified mount points. + # mount_points = ["/"] + + ## Ignore mount points by filesystem type. + ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"] + + [[inputs.diskio]] + + [[inputs.kernel]] + + [[inputs.mem]] + + # Get the number of processes and group them by status + [[inputs.processes]] + # no configuration + + + # Read metrics about swap memory usage + [[inputs.swap]] + # no configuration + + + # Read metrics about system load & uptime + [[inputs.system]] + # no configuration + + + # Read metrics about network interface usage + [[inputs.net]] + ## By default, telegraf gathers stats from any up interface (excluding loopback) + ## Setting interfaces will tell it to gather these explicit interfaces, + ## regardless of status. + ## + ## interfaces = ["eth0"] + +- name: Docker Container Setup + become: true + community.docker.docker_container: + name: telegraf + image: telegraf + state: started + restart_policy: unless-stopped + #user: root + entrypoint: "telegraf" + security_opts: + - apparmor=unconfined + pull: yes + volumes: + - "{{ config_file.host_path }}:/etc/telegraf" + - /var/run/docker.sock:/var/run/docker.sock + - /:/hostfs:ro + env: + HOST_ETC: /hostfs/etc + HOST_PROC: /hostfs/proc + HOST_SYS: /hostfs/sys + HOST_VAR: /hostfs/var + HOST_RUN: /hostfs/run + HOST_MOUNT_PREFIX: /hostfs \ No newline at end of file diff --git a/roles/myLimbo.docker.telegraf/vars/main.yml b/roles/myLimbo.docker.telegraf/vars/main.yml new file mode 100644 index 0000000..e90f00b --- /dev/null +++ b/roles/myLimbo.docker.telegraf/vars/main.yml @@ -0,0 +1,10 @@ +--- +config_file: + host_path: /etc/myLimbo/docker-telegraf +hostname: "????" +influxdb2: + org: "?????" + url: "?????" + token: "????" + bucket: "?????" +