背景:日常作为一位运维工程师,经常在思考AI怎么结合到日常工作中来,最近随着各类中间件MCP server的推出感觉可以实现很多有意思的操作。
本文简单介绍下如何使用大模型通过mcp服务进行Grafana的相关操作。
环境介绍:
当前mcp-server版本服务支持的能力如下
datasources:query
list_teams
teams:read
teams:*
teams:id:1
list_users_by_org
users:read
global.users:*
global.users:id:123
search_dashboards
dashboards:read
dashboards:*
dashboards:uid:abc123
get_dashboard_by_uid
update_dashboard
dashboards:create
dashboards:write
folders:*
folders:uid:xyz789
get_dashboard_panel_queries
list_datasources
datasources:read
datasources:*
get_datasource_by_uid
datasources:uid:prometheus-uid
get_datasource_by_name
datasources:uid:loki-uid
query_prometheus
list_prometheus_metric_names
list_prometheus_label_names
list_prometheus_label_values
list_incidents
create_incident
add_activity_to_incident
get_incident
query_loki_logs
list_loki_label_names
list_loki_label_values
query_loki_stats
list_alert_rules
alert.rules:read
folders:uid:alerts-folder
get_alert_rule_by_uid
list_contact_points
alert.notifications:read
list_oncall_schedules
grafana-oncall-app.schedules:read
get_oncall_shift
get_current_oncall_users
list_oncall_teams
grafana-oncall-app.user-settings:read
list_oncall_users
get_sift_investigation
get_sift_analysis
list_sift_investigations
find_error_pattern_logs
find_slow_requests
list_pyroscope_label_names
datasources:uid:pyroscope-uid
list_pyroscope_label_values
list_pyroscope_profile_types
fetch_pyroscope_profile
get_assertions
generate_deeplink
更多的介绍和细节可以去看官方的git地址:MCP server for Grafana
整体的部署操作相对简单:
我用的macOS m4的芯片所以下载了darwin的 arm的包,其他平台的同理
在Grafana中创建需要的api key,我用的版本是v10.4.2位置在 menu -> administrator -> users and access -> service accounts中
创建用户后,生成 account token
注意该token只会显示一次,记得保存下来
我使用的是chatbox,这个比较简单,如图添加mcp服务
其中类型选择本地:信息就是刚才下载的mcp-grafana的可执行文件的地址
环境变量中要配置两个参数:
然后测试,保存
chatbox本身支持市面上绝大多数的模型提供商,也支持自建的ollama服务,这里我用的deepseek,配置比较简单, 填写上key直接使用即可
现在就可以通过对话进行一些grafana的查询操作等:
通过图片可以看到我其实也添加了gitlab iterm的mcp用来进行一些项目代码,等测试操作
不过iterm这个与终端交互让我感觉蠢蠢的,着实感觉就是可以,但是没必要中间来这么一道,不过也在思考比如通过终端,或者jenkins类的结合,是否可以通过与模型对话,完成项目部署,程序发布等操作,还在探索
有任何不对或不妥之处 欢迎大家讨论
这个离生产力很近了
Featured Collection
Popular Ranking
Popular Events
本文简单介绍下如何使用大模型通过mcp服务进行Grafana的相关操作。
环境介绍:
当前mcp-server版本服务支持的能力如下
Tools
datasources:query
list_teams
teams:read
teams:*
orteams:id:1
list_users_by_org
users:read
global.users:*
orglobal.users:id:123
search_dashboards
dashboards:read
dashboards:*
ordashboards:uid:abc123
get_dashboard_by_uid
dashboards:read
dashboards:uid:abc123
update_dashboard
dashboards:create
,dashboards:write
dashboards:*
,folders:*
orfolders:uid:xyz789
get_dashboard_panel_queries
dashboards:read
dashboards:uid:abc123
list_datasources
datasources:read
datasources:*
get_datasource_by_uid
datasources:read
datasources:uid:prometheus-uid
get_datasource_by_name
datasources:read
datasources:*
ordatasources:uid:loki-uid
query_prometheus
datasources:query
datasources:uid:prometheus-uid
datasources:uid:prometheus-uid
list_prometheus_metric_names
datasources:query
datasources:uid:prometheus-uid
list_prometheus_label_names
datasources:query
datasources:uid:prometheus-uid
list_prometheus_label_values
datasources:query
datasources:uid:prometheus-uid
list_incidents
create_incident
add_activity_to_incident
get_incident
query_loki_logs
datasources:query
datasources:uid:loki-uid
list_loki_label_names
datasources:query
datasources:uid:loki-uid
list_loki_label_values
datasources:query
datasources:uid:loki-uid
query_loki_stats
datasources:query
datasources:uid:loki-uid
list_alert_rules
alert.rules:read
folders:*
orfolders:uid:alerts-folder
get_alert_rule_by_uid
alert.rules:read
folders:uid:alerts-folder
list_contact_points
alert.notifications:read
list_oncall_schedules
grafana-oncall-app.schedules:read
get_oncall_shift
grafana-oncall-app.schedules:read
get_current_oncall_users
grafana-oncall-app.schedules:read
list_oncall_teams
grafana-oncall-app.user-settings:read
list_oncall_users
grafana-oncall-app.user-settings:read
get_sift_investigation
get_sift_analysis
list_sift_investigations
find_error_pattern_logs
find_slow_requests
list_pyroscope_label_names
datasources:query
datasources:uid:pyroscope-uid
list_pyroscope_label_values
datasources:query
datasources:uid:pyroscope-uid
list_pyroscope_profile_types
datasources:query
datasources:uid:pyroscope-uid
fetch_pyroscope_profile
datasources:query
datasources:uid:pyroscope-uid
get_assertions
generate_deeplink
更多的介绍和细节可以去看官方的git地址:MCP server for Grafana
整体的部署操作相对简单:
我用的macOS m4的芯片所以下载了darwin的 arm的包,其他平台的同理
在Grafana中创建需要的api key,我用的版本是v10.4.2位置在 menu -> administrator -> users and access -> service accounts中
创建用户后,生成 account token
注意该token只会显示一次,记得保存下来
我使用的是chatbox,这个比较简单,如图添加mcp服务
其中类型选择本地:信息就是刚才下载的mcp-grafana的可执行文件的地址
环境变量中要配置两个参数:
然后测试,保存
chatbox本身支持市面上绝大多数的模型提供商,也支持自建的ollama服务,这里我用的deepseek,配置比较简单, 填写上key直接使用即可
现在就可以通过对话进行一些grafana的查询操作等:
通过图片可以看到我其实也添加了gitlab iterm的mcp用来进行一些项目代码,等测试操作
不过iterm这个与终端交互让我感觉蠢蠢的,着实感觉就是可以,但是没必要中间来这么一道,不过也在思考比如通过终端,或者jenkins类的结合,是否可以通过与模型对话,完成项目部署,程序发布等操作,还在探索
有任何不对或不妥之处 欢迎大家讨论