Skip to content

Instantly share code, notes, and snippets.

@tarasowski
Created January 3, 2024 11:32
Show Gist options
  • Save tarasowski/5095a24c936b3c3f5af533e0ab5b722d to your computer and use it in GitHub Desktop.
Save tarasowski/5095a24c936b3c3f5af533e0ab5b722d to your computer and use it in GitHub Desktop.
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target
[Service]
User=ec2-user
#Group=ec2-user
WorkingDirectory=/opt/prometheus
Restart=on-failure
# Change this line if Prometheus is located at a different path
ExecStart=/opt/prometheus/prometheus \
--config.file=/opt/prometheus/prometheus.yml
[Install]
WantedBy=multi-user.target
@tarasowski
Copy link
Author

sudo vi /etc/systemd/system/prometheus.service

[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target

[Service]
User=ec2-user
#Group=ec2-user
WorkingDirectory=/opt/prometheus
Restart=on-failure

# Change this line if Prometheus is located at a different path
ExecStart=/opt/prometheus/prometheus \
  --config.file=/opt/prometheus/prometheus.yml

[Install]
WantedBy=multi-user.target

change premissions

sudo chown -R ec2-user: /opt/prometheus/data

recursively for all data inside of the folder

sudo chown -R ec2-user: /opt/prometheus

reload system manager

sudo systemctl daemon-reload

start prometheus

sudo systemctl start prometheus

enable to start on boot

sudo systemctl enable prometheus

check the status of the app

sudo systemctl status prometheus

sudo systemctl restart prometheus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment