Compare commits
2
Commits
a4de74350d
...
783b658724
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
783b658724 | ||
|
|
d4481907b0 |
@@ -0,0 +1,30 @@
|
|||||||
|
# Grafana Aloy
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
collections:
|
||||||
|
- name: grafana.grafana
|
||||||
|
version: 6.1.0
|
||||||
|
```
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
``` yaml
|
||||||
|
---
|
||||||
|
- name: Grafana Alloy
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: myLimbo.globals.grafana_alloy
|
||||||
|
vars:
|
||||||
|
alloy_version: "1.19.0"
|
||||||
|
prometheus:
|
||||||
|
remote_write:
|
||||||
|
endpoint:
|
||||||
|
url: "{{ prometheus_address }}/api/v1/write"
|
||||||
|
loki:
|
||||||
|
endpoint:
|
||||||
|
url: "{{ loki_address }}/loki/api/v1/push"
|
||||||
|
labels:
|
||||||
|
zone: srv-vlan
|
||||||
|
---
|
||||||
|
```
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
galaxy_info:
|
||||||
|
author: mf
|
||||||
|
description: grafana alloy 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: []
|
||||||
|
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||||
|
# if you add dependencies to this list.
|
||||||
|
collections:
|
||||||
|
- grafana.alloy
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
- name: Render Alloy config
|
||||||
|
set_fact:
|
||||||
|
__mylimbo_globals_alloy_config_content: "{{ lookup('template', 'template/config.alloy.j2') }}"
|
||||||
|
|
||||||
|
- name: Install Alloy
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: grafana.grafana.alloy
|
||||||
|
vars:
|
||||||
|
# documentation:
|
||||||
|
# https://grafana.com/docs/grafana-cloud/observe-and-act/send-data/alloy/monitor/monitor-linux/
|
||||||
|
alloy_config: "{{ __mylimbo_globals_alloy_config_content }}"
|
||||||
|
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
// metrics - prometheus srv
|
||||||
|
prometheus.remote_write "prom_srv" {
|
||||||
|
endpoint {
|
||||||
|
url = "{{ prometheus.remote_write.endpoint.url }}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// metrics - scrape config
|
||||||
|
prometheus.scrape "integrations_node_exporter" {
|
||||||
|
scrape_interval = "15s"
|
||||||
|
targets = discovery.relabel.integrations_node_exporter.output
|
||||||
|
forward_to = [prometheus.remote_write.prom_srv.receiver]
|
||||||
|
}
|
||||||
|
|
||||||
|
// metrics - relabel
|
||||||
|
discovery.relabel "integrations_node_exporter" {
|
||||||
|
targets = prometheus.exporter.unix.integrations_node_exporter.targets
|
||||||
|
|
||||||
|
rule {
|
||||||
|
target_label = "instance"
|
||||||
|
replacement = constants.hostname
|
||||||
|
}
|
||||||
|
|
||||||
|
rule {
|
||||||
|
target_label = "job"
|
||||||
|
replacement = "node-exporter"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// metrics - node exporter
|
||||||
|
prometheus.exporter.unix "integrations_node_exporter" {
|
||||||
|
disable_collectors = ["ipvs", "btrfs", "infiniband", "xfs", "zfs"]
|
||||||
|
enable_collectors = ["meminfo"]
|
||||||
|
|
||||||
|
filesystem {
|
||||||
|
fs_types_exclude = "^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|tmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$"
|
||||||
|
mount_points_exclude = "^/(dev|proc|run/credentials/.+|sys|var/lib/docker/.+)($|/)"
|
||||||
|
mount_timeout = "5s"
|
||||||
|
}
|
||||||
|
|
||||||
|
netclass {
|
||||||
|
ignored_devices = "^(veth.*|cali.*|[a-f0-9]{15})$"
|
||||||
|
}
|
||||||
|
|
||||||
|
netdev {
|
||||||
|
device_exclude = "^(veth.*|cali.*|[a-f0-9]{15})$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// logs loki
|
||||||
|
loki.write "loki_srv" {
|
||||||
|
endpoint {
|
||||||
|
url = "{{ loki.endpoint.url }}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// logs - journald
|
||||||
|
loki.source.journal "logs_journal_scrape" {
|
||||||
|
max_age = "24h0m0s"
|
||||||
|
relabel_rules = discovery.relabel.logs_journal_scrape.rules
|
||||||
|
forward_to = [loki.write.loki_srv.receiver]
|
||||||
|
|
||||||
|
labels = {
|
||||||
|
host = "{{ inventory_hostname }}",
|
||||||
|
{% if loki.labels is defined and loki.labels %}
|
||||||
|
{% for key, value in loki.labels.items() %}
|
||||||
|
{{ key }} = "{{ value }}",
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// logs - journald - relabel
|
||||||
|
discovery.relabel "logs_journal_scrape" {
|
||||||
|
targets = []
|
||||||
|
|
||||||
|
rule {
|
||||||
|
source_labels = ["__journal__systemd_unit"]
|
||||||
|
target_label = "systemd_unit"
|
||||||
|
}
|
||||||
|
|
||||||
|
rule {
|
||||||
|
source_labels = ["__journal_syslog_identifier"]
|
||||||
|
target_label = "syslog_identifier"
|
||||||
|
}
|
||||||
|
|
||||||
|
rule {
|
||||||
|
source_labels = ["__journal__transport"]
|
||||||
|
target_label = "journal_transport"
|
||||||
|
}
|
||||||
|
|
||||||
|
rule {
|
||||||
|
source_labels = ["__journal_priority_keyword"]
|
||||||
|
target_label = "level"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user