1
0
Fork 0
mirror of https://github.com/sdr-enthusiasts/docker-adsb-ultrafeeder.git synced 2024-11-25 15:20:10 +00:00
This commit is contained in:
kx1t 2023-03-30 16:14:38 -04:00
parent 0257175207
commit 783b4eb02e

View file

@ -30,17 +30,40 @@ Now recreate the ultrafeeder container (`docker-compose up -d ultrafeeder`) and
On the machine where you will run Prometheus and Grafana, create a docker-compose file in the `/opt/grafana` directory: On the machine where you will run Prometheus and Grafana, create a docker-compose file in the `/opt/grafana` directory:
```bash ```bash
mkdir -p -m777 /opt/grafana && cd /opt/grafana mkdir -p -m777 /opt/grafana/grafana/appdata /opt/grafana/prometheus/config /opt/grafana/prometheus/data && cd /opt/grafana
cat > docker-compose.yml cat > docker-compose.yml
``` ```
Now paste in the following text: Now paste in the following text *):
*) The volume definition structure is written this way purposely to ensure that the containers can place files in the persistent directories. Do not try to "directly" map volumes (`/opt/grafana/grafana/appdata:/var/lib/grafana`).
<details> <details>
<summary>&lt;&dash;&dash; Click the arrow to see the <code>docker-compose.yml</code> text</summary> <summary>&lt;&dash;&dash; Click the arrow to see the <code>docker-compose.yml</code> text</summary>
```yaml ```yaml
version: '3.9' version: '3.9'
volumes:
grafana:
driver: local
driver_opts:
type: none
device: "/opt/grafana/grafana/appdata"
o: bind
prom-config:
driver: local
driver_opts:
type: none
device: "/opt/grafana/prometheus/config"
o: bind
prom-data:
driver: local
driver_opts:
type: none
device: "/opt/grafana/prometheus/data"
o: bind
services: services:
grafana: grafana:
image: grafana/grafana-oss:latest image: grafana/grafana-oss:latest
@ -55,7 +78,7 @@ services:
ports: ports:
- 3000:3000 - 3000:3000
volumes: volumes:
- /opt/grafana/grafana/appdata:/var/lib/grafana - grafana:/var/lib/grafana
prometheus: prometheus:
image: prom/prometheus image: prom/prometheus
@ -65,8 +88,8 @@ services:
tmpfs: tmpfs:
- /tmp - /tmp
volumes: volumes:
- /opt/grafana/prometheus/config:/etc/prometheus - prom-config:/etc/prometheus
- /opt/grafana/prometheus/data:/prometheus - prom-data:/prometheus
ports: ports:
- 9090:9090 - 9090:9090
``` ```
@ -76,9 +99,7 @@ services:
Once you have created and saved this `docker-compose.yml` file, give these commands to create the mapped volumes: Once you have created and saved this `docker-compose.yml` file, give these commands to create the mapped volumes:
```bash ```bash
docker compose up -d sudo mkdir -p -m777 /opt/grafana/appdata /opt/grafana/prometheus/config /opt/grafana/prometheus/data
docker compose stop prometheus
docker compose stop grafana
``` ```
Now, you should be able to see the following directories: Now, you should be able to see the following directories:
@ -86,53 +107,28 @@ Now, you should be able to see the following directories:
- `/opt/grafana/prometheus/config` - `/opt/grafana/prometheus/config`
- `/opt/grafana/prometheus/data` - `/opt/grafana/prometheus/data`
## Step 3: Configuring Prometheus Download and create Grafana and Prometheus for the first time with this command:
Prometheus needs to be told where to look for the data from the ultrafeeder. We will create a target prometheus configuration file that does this, please copy and paste the following:
<details>
<summary>&lt;&dash;&dash; Click the arrow to see the shell script</summary>
```bash ```bash
sudo touch /opt/grafana/prometheus/config/prometheus.yml cd /opt/grafana
sudo chmod a+rwx /opt/grafana/prometheus/config/prometheus.yml docker compose up -d
cat > /opt/grafana/prometheus/config/prometheus.yml <<EOF
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
alerting:
alertmanagers:
- static_configs:
- targets:
rule_files:
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: 'readsb'
static_configs:
- targets: ['ip_of_ultrafeeder_machine:9273', 'ip_of_ultrafeeder_machine:9274']
EOF
``` ```
</details> ## Step 3: Configuring Prometheus
Make sure to change `ip_of_ultrafeeder_machine` to the IP address or hostname of your ultrafeeder machine. Prometheus needs to be told where to look for the data from the ultrafeeder. We will create a target prometheus configuration file that does this, please copy and paste the following. Make sure to replace `ip_of_ultrafeeder_machine` with the IP address or hostname of the machine where `ultrafeeder` is running:
Once the file has been updated, issue the command `docker compose up -d` in the application directory to apply the changes and bring up the `prometheus` and `grafana` containers. ```bash
docker exec -it prometheus sh -c "echo -e \" - job_name: 'readsb'\n static_configs:\n - targets: ['ip_of_ultrafeeder_machine:9273', 'ip_of_ultrafeeder_machine:9274']\" >> /etc/prometheus/prometheus.yml"
docker stop prometheus
docker compose up -d
```
At this point we will need to add a collector definition to `prometheus` and restart with the new configuration. (If you screw this up, **do NOT** re-run the command. Instead, try `sudo nano /opt/grafana//prometheus/config/prometheus.yml` and fix it that way.)
1. Issue the command `docker exec -it prometheus sh -c "echo -e \" - job_name: 'readsb'\n static_configs:\n - targets: ['readsb:9273']\" >> /etc/prometheus/prometheus.yml"` ## Accessing Prometheus and Grafana via your browser
2. Issue the command `docker stop prometheus`
3. Issue the command `docker compose up -d`
You should also be able to point your web browser at: You should be able to point your web browser at:
* `http://docker.host.ip.addr:9090/` to access the `prometheus` console. * `http://docker.host.ip.addr:9090/` to access the `prometheus` console.
* `http://docker.host.ip.addr:3000/` to access the `grafana` console, use admin/admin as initial credentials, you should be prompted to change the password on first login. * `http://docker.host.ip.addr:3000/` to access the `grafana` console, use admin/admin as initial credentials, you should be prompted to change the password on first login.