- Introduction
- Features
- Getting Started
- Generate Self-Signed SSL Certificate
- Updated Grafana Version
- Usage
- Monitoring Container Logs
- Contributing
- License
This project provides a containerized version of Grafana, an open-source platform for monitoring and observability. It's designed to be easy to deploy and manage, making it ideal for environments that benefit from containerization. The Grafana Container offers a scalable way to visualize and analyze metrics, logs, and traces from your environment.
- Easy to deploy Grafana in a containerized environment.
- Configurable settings for different monitoring needs.
- Integration with various data sources.
- Docker and Docker Compose installed on your system.
- Basic understanding of containerization and Grafana.
- Clone the repository:
git clone https://github.com/benjisho/grafana-container.git
- Navigate to the cloned directory:
cd grafana-container
Note: This section is relevant if you haven't generated a well-known SSL certificate from a certified authority. These will guide you on creating a self-signed certificate, useful for testing or development purposes.
- Run the following command to generate a 2048-bit RSA private key, which is used to decrypt traffic:
openssl genrsa -out certs/server.key 2048
- Run the following command to generate a certificate, using the private key from the previous step.
openssl req -new -key certs/server.key -out certs/server.csr
- Run the following command to self-sign the certificate with the private key, for a period of validity of 365 days:
openssl x509 -req -days 365 -in certs/server.csr -signkey certs/server.key -out certs/server.crt
The Grafana container now uses version 12.0.1-ubuntu
. This version is based on Ubuntu and provides enhanced compatibility and stability. Ensure that your environment is compatible with this version before deployment.
- The Ubuntu-based image may have different dependencies compared to the Alpine-based images. Ensure that any custom plugins or configurations are compatible.
- If you encounter issues, refer to the Grafana Docker documentation for troubleshooting.
To start the Grafana and Nginx services, use the following command:
docker compose up -d
This will pull the specified Grafana version (12.0.1-ubuntu
) and start the services.
Copy .env.example
to .env
and adjust the variables:
cp .env.example .env
GRAFANA_ADMIN_USER
andGRAFANA_ADMIN_PASSWORD
set the initial Grafana credentials.NGINX_SERVER_NAME
defines the hostname served by Nginx.SSL_CERT_PATH
andSSL_KEY_PATH
point to your certificate files.
You can change exposed ports or paths by editing docker-compose.yml
.
Grafana stores its data in /var/lib/grafana
. The compose file uses a named volume grafana-storage
. To persist data on the host, map a directory instead:
volumes:
- ./grafana-data:/var/lib/grafana
- Ensure the SSL certificates referenced in
.env
exist and are readable by Nginx. - If Grafana cannot write to the data directory, adjust its permissions:
sudo chown -R 472:472 ./grafana-data
To use the Grafana Container:
- Start the container:
docker compose up -d
- Access Grafana by navigating to
https://localhost
in your web browser. - Default login user is usually
admin
for both username and password (unless configured otherwise). - Configure data sources and dashboards as per your requirements.
For example, to add a Prometheus data source:
- Navigate to
Configuration > Data Sources
in the Grafana UI.- Click
Add data source
, and selectPrometheus
.- Enter the URL of your Prometheus server, and click
Save & Test
.
- Explore and create dashboards to visualize your data. For more detailed usage instructions, refer to the Grafana documentation.
This section guides you on how to use docker compose logs -f
to follow the log output of the Grafana and Nginx containers in real-time.
docker compose logs -f
: This command fetches the logs of the containers.- The
-f
flag means "follow", allowing you to view the log output in real-time.
-
Navigate to where your
docker-compose.yml
file is located. -
Execute the following command to follow the logs for all services:
docker compose logs -f
This will display a continuous stream of logs of all containers in the
docker-compose.yml
. -
If you want to follow the logs of a specific container from the
docker-compose.yml
, specify the service name. For example, to follow only the Grafana logs, use:docker compose logs -f grafana
Similarly, for Nginx logs:
docker compose logs -f nginx
- Grafana Logs: Look for indications of successful startup, connection to data sources, and any error messages related to querying data.
- Nginx Logs: These logs will include information about HTTP requests, responses, and any errors related to network connections or SSL/TLS certificates.
Note: Keep in mind that the volume of logs can be high depending on the level of activity. It's advisable to filter or search through the logs for specific keywords related to the issues you're investigating.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.