Appwrite is an open-source, self-hosted Backend-as-a-Service that makes app development easier with a suite of SDKs and APIs to accelerate app development. #30DaysOfAppwrite is a month-long event focused on giving developers a walkthrough of all of Appwrite's features, starting from the basics to more advanced features like Cloud Functions! Alongside we will also be building a fully-featured Medium clone to demonstrate how these concepts can be applied when building a real-world app. We also have some exciting prizes for developers who follow along with us!
Welcome to Day 29 👋 - today marks the last day of #30DaysOfAppwrite, and we thought it would be a fun little exercise to show you how you can add external services to the Appwrite stack and make it work seamlessly! We love Dashboards, and we thought it would be great to add Grafana support to Appwrite.
Appwrite doesn't come with Grafana out of the box for several reasons. First, you may already have your own set of monitoring tools in your stack, and we believe that our stack should be un-opinionated and allow you to work with the tools you feel comfortable with. The second reason is that we try to ship the Appwrite setup with minimal components to make Appwrite easy to start but still flexible enough to grow.
We will be creating two Dashboards: one for monitoring Appwrite's usage stats and one for monitoring your Server stats.
The first step is to add the Grafana service to Appwrite's
Next, you need to add the
appwrite-grafana volume to the list of all volumes. This will allow your Grafana container to persist data.
docker-compose up -d
We don't need any additional configuration for your first Dashboard in our services. Now head over to
http://localhost:3000 to configure Grafana. You can log in using the default credentials:
username : admin
password : admin
You will be prompted to enter a new password, and it is highly recommended that you change the default password. Learn more about managing users and passwords in their official guide.
The first step is to configure your Data Source. In our case, we will be using the InfluxDB plugin.
Once you add the InfluxDB data source, it's time to configure it. Here, you need to fill in the values of 2 fields,
- URL - http://influxdb:8086
- Database - telegraf
Finally, click Save and Test to check your database connection. If all goes well, you will see a success message.
The next step is to import the Dashboard we created for you. Head to the Grafana's Dashboard Library and copy the ID of our Dashboard.
You can then Import the Dashboard in your Grafana instance like so.
And that's it! You should now see this fancy Dashboard
The next Dashboard is one that will monitor our server metrics. This includes CPU usage, Disk I/O, Network I/O, and much more. This Dashboard requires some additional info, so we need to make a few changes in our
telegraf Docker image to make this information available.
We'll start by cloning Appwrite's
git clone https://github.com/appwrite/docker-telegraf.git
We need to make more metrics available to the collector. Add the following lines to line 83
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = false
ignore_fs = ["tmpfs", "devtmpfs", "devfs"]
Now we need to build a new Docker image using the changes we made.
docker build -t telegraf-local .
Once this build is complete, we can make use of our new
telegraf-local image in the main Appwrite
docker-compose.yml. Replace the
appwrite/telegraf:1.1.0 image in line 434 with our
docker-compose up -d --remove-orphans from your
appwrite directory to restart your services.
Now head over to your Grafana Dashboard and import this new Dashboard the same way as you did the previous one, and if everything goes well, you should see the following Dashboard!
And just like that, you now have access to all your server information in one place! This was just the tip of the iceberg! Grafana has many more amazing features. It's completely open-source, has support for over 30 Data Sources, has support for Alerting etc. You can set up custom alerts, and Grafana will continuously evaluate and send notifications to systems like Slack, PagerDuty, VictorOps, and OpsGenie. You can learn more about all of Grafana's features in their dedicated tutorials section.
Feel free to reach out to us on Discord if you would like to learn more about Appwrite, Aliens, or Unicorns 🦄. Stay tuned for tomorrow's article! Until then 👋