包阅导读总结
1.
关键词:Grafana Mimir、Ansible、DevOps、配置管理、指标监测
2.
总结:本文介绍了如何使用 Ansible 部署 Grafana Mimir,包括前期准备、安装 Ansible 集合、创建库存文件和配置文件、使用 Mimir Ansible 角色进行配置以及检查指标可用性等内容。
3.
主要内容:
– 介绍作者 Gerard van Engelen 及其工作方式
– 说明 Ansible 受系统管理员和 DevOps 专业人员欢迎
– 指出 Grafana Ansible 集合自 2022 年支持用户,现新增 Grafana Mimir 部署
– 开始前准备
– 3 台有 SSH 访问权限的 Linux 主机
– 安装 Ansible
– 安装 Grafana Ansible 集合
– 创建 Ansible 库存文件
– 创建 ansible.cfg 文件
– 使用 Mimir Ansible 角色创建 Ansible 剧本
– 配置 Mimir
– 运行剧本
– 检查 Mimir 中指标是否可用
– 设置负载均衡
– 执行测试查询
– 排查无数据问题
思维导图:
文章地址:https://grafana.com/blog/2024/07/23/how-to-set-up-grafana-mimir-using-ansible/
文章来源:grafana.com
作者:Gerard van Engelen
发布时间:2024/7/23 11:57
语言:英文
总字数:906字
预计阅读时间:4分钟
评分:90分
标签:Grafana Mimir,Ansible,DevOps,配置管理,监控
以下为原文内容
本内容来源于用户推荐转载,旨在分享知识与观点,如有侵权请联系删除 联系邮箱 media@ilingban.com
Gerard van Engelen is a seasoned DevOps engineer who ensures the quality of products by drawing parallels between complex issues and simpler, everyday scenarios. This approach helps in delivering value, ensuring that products are not only built correctly but also offer the right functionalities.
Ansible is popular with system administrators and DevOps professionals who use it for automating IT tasks such as configuration management, application deployment, and orchestration.
Since 2022, Grafana Labs has supported Ansible users through its Grafana Ansible collection. With Grafana, OpenTelemetry Collector, Grafana Alloy, and modules for provisioning Grafana resources, the Ansible collection is there to help Grafana Administrators. And now we’ve added Grafana Mimir deployments to support Mimir configurations as well.
In this guide we’ll walk you through how to use the mimir
role with the Grafana Ansible collection to deploy and manage Mimir across multiple Linux hosts. We’ll then show you how to explore your data in Grafana.
Before you begin
To get started, you should have the following:
- 3 Linux hosts with SSH access and sufficient permissions
- Ansible installed on your base system
Install the Grafana Ansible collection
The Mimir role is available in the Grafana Ansible collection as of the 5.0.0 release.
To install the Grafana Ansible collection, run this command:
ansible-galaxy collection install grafana.grafana:4.0.0
Create an Ansible inventory file
Next, you will set up your hosts and create an inventory file.
- Create an Ansible inventory file.
An Ansible inventory, which resides in a file named inventory
, lists each host IP on a separate line, like this (3 hosts shown):
146.190.208.216 # hostname = mimir-01146.190.208.190 # hostname = mimir-02146.190.208.190 # hostname = mimir-03
Note: If you are copying the above file, remove the comments (#).
- Create an
ansible.cfg
file within the same directory asinventory
, with the following values:
[defaults]inventory = inventory # Path to the inventory fileprivate_key_file = ~/.ssh/id_rsa # Path to my private SSH Keyremote_user=root
Use the Mimir Ansible role
Next you will create an Ansible playbook that calls the mimir
role from the grafana.grafana
Ansible collection.
To use the Mimir Ansible role:
First, create a file named deploy-mimir.yml
in the same directory as ansible.cfg
and inventory and add the configuration below.
Just like other roles, Mimir is now available via Ansible Galaxy. You can install the collection using the command below:
ansible-galaxy collection install grafana.grafana
After the collection is installed, you can use the mimir
role in your playbook like this:
- hosts: all roles: - role: grafana.grafana.mimir
This way, Ansible knows to look for the mimir
role within the grafana.grafana
collection. Ensure your Ansible configuration and version support collections, as this feature was introduced in Ansible 2.9.
Configuring Mimir using the Ansible collection
The Mimir role is highly configurable due to the config templating. If you want to run Mimir in HA, just add the following vars to your playbook:
- name: Install Mimir hosts: all become: truetasks: - name: Install Mimir ansible.builtin.include_role: name: grafana.grafana.mimir vars: mimir_storage: # You can use different object store backends, use Minio for local development storage: backend: s3 s3: endpoint: {{ endpoint }} access_key_id: {{ acces_key_id }} secret_access_key: {{ secret_acces_key }} insecure: true # False when using https bucket_name: mimir # Blocks storage requires a prefix when using a common object storage bucket. mimir_blocks_storage: storage_prefix: blocks tsdb: dir: "{{ mimir_working_path}}/ingester" # Use memberlist, a gossip-based protocol, to enable the 3 Mimir replicas to communicate mimir_memberlist: join_members: - mimir-01:7946 - mimir-02:7946 - mimir-03::7946
The playbook calls the mimir
role from the grafana.grafana
Ansible collection. The Mimir configuration in this playbook installs Mimir on three hosts, makes sure the hosts communicate with each other, and enables use of the object storage backend.
Refer to the Grafana Ansible documentation to understand the other variables you can pass to the mimir
role.
To run the playbook, run this command:
ansible-playbook deploy-mimir.yml
Note: You can place the
deploy-mimir.yml
,ansible.cfg
, andinventory
files in different directories based on your needs.
Check that metrics are available in Mimir
Since we’re running Mimir in HA by replication, you’ll need to set up your own load balancing to be able to use Mimir to its full potential. If you’ve set up load balancing, you’ll be able to add your datasource in Grafana using your selected hostname.
To check metrics:
- Find the Explore section. Look for the Explore icon (it looks like a compass) on the left-side vertical navigation bar in Grafana and click it.
- Select Your Prometheus data source. At the top of the page, there’s a dropdown menu. Use it to pick the Prometheus data source you’ve added.
- Run a test query. Type in the query
{name="mimir-01"}
. - Check metrics. After running the query, if you see a graph and a table with data (similar to the example shown in the image below), it means your metrics are correctly being fetched and displayed.
- Explore additional metrics. Explore other metrics—like CPU load, memory usage, disk I/O, network bandwidth—and create dashboards to gain insights into your system’s performance.
If you don’t see any data, it could mean that metrics aren’t being collected as expected. To troubleshoot, check the status of your Mimir service by running this command:
sudo systemctl status mimir.service
If the Mimir service isn’t running, there might be an issue with the configuration syntax, or you might need to debug further. For help with this, take a look at the documentation available on configuring Mimir correctly.