Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Skrypt dostosowany do OS o architekturze AMD64
- apt-get -y update && apt-get install -y nano \\
- && apt-get install -y curl \\
- && apt-get install -y net-tools \\
- && apt-get install -y nc \\
- && apt-get install -y unzip \\
- && apt-get install traceroute
- cd /home/
- mkdir MONITORING
- cd MONITORING/
- # Node Exporter
- wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz
- tar -xvzf node_exporter-1.3.1.linux-amd64.tar.gz
- rm -f -xvzf node_exporter-1.3.1.linux-amd64.tar.gz
- cd node_exporter-1.3.1.linux-amd64
- chmod +x node_exporter
- touch /etc/systemd/system/node_exporter.service
- tee /etc/systemd/system/node_exporter.service <<EOF
- [Unit]
- Description=System service for NODE EXPORTER - system metrics exportation
- Wants=network.target
- After=syslog.target network-online.target
- [Service]
- Type=simple
- ExecStart=/home/MONITORING/node_exporter-1.3.1.linux-amd64/node_exporter
- User=root
- Restart=on-failure
- RestartSec=10
- KillMode=process
- [Install]
- WantedBy=multi-user.target
- EOF
- chmod 640 /etc/systemd/system/node_exporter.service
- systemctl daemon-reload
- systemctl enable node_exporter.service
- systemctl start node_exporter.service
- # Promtail
- wget https://github.com/grafana/loki/releases/download/v2.4.2/promtail-linux-amd64.zip
- unzip promtail-linux-amd64.zip
- tee /home/MONITORING/promtail-config.yaml << EOF
- server:
- http_listen_port: 9080
- grpc_listen_port: 0
- positions:
- filename: /tmp/positions.yaml
- clients:
- - url: 'http://192.168.75.203:3100/loki/api/v1/push'
- scrape_configs:
- - job_name: journal
- journal:
- max_age: 12h
- labels:
- job: systemd-journal
- relabel_configs:
- - source_labels: ['__journal__systemd_unit']
- target_label: 'unit'
- - job_name: containers
- pipeline_stages:
- - json:
- expressions:
- output: log
- stream: stream
- attrs:
- - regex:
- expression: (?P<image_name>(?:[^|]*[^|])).(?P<container_name>(?:[^|]*[^|])).(?P<image_id>(?:[^|]*[^|])).(?P<container_id>(?:[^|]*[^|]))
- source: tag
- - timestamp:
- format: RFC3339Nano
- source: time
- - labels:
- tag:
- stream:
- image_name:
- container_name:
- image_id:
- container_id:
- - output:
- source: output
- static_configs:
- - targets:
- - localhost
- labels:
- job: containerlogs
- __path__: /var/lib/docker/containers/*/*log
- - job_name: system
- static_configs:
- - targets:
- - localhost
- labels:
- host: $HOSTNAME
- job: varlogs
- __path__: /var/log/*log
- EOF
- touch /etc/systemd/system/promtail.service
- tee /etc/systemd/system/promtail.service <<EOF
- [Unit]
- Description=System service for Promtail - Loki agent for pushing logs
- Wants=network.target
- After=syslog.target network-online.target
- [Service]
- Type=simple
- ExecStart=/home/MONITORING/promtail-linux-amd64 -config.file=/home/MONITORING/promtail-config.yaml
- User=root
- Restart=on-failure
- RestartSec=10
- KillMode=process
- [Install]
- WantedBy=multi-user.target
- EOF
- chmod 640 /etc/systemd/system/promtail.service
- systemctl daemon-reload
- systemctl enable promtail.service
- systemctl start promtail.service
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement