The open-source platform for monitoring and observability
Grafana allows you to query, visualize, alert on and understand your metrics no matter where they are stored. Create, explore, and share dashboards with your team and foster a data-driven culture:
- Visualizations: Fast and flexible client side graphs with a multitude of options. Panel plugins offer many different ways to visualize metrics and logs.
- Dynamic Dashboards: Create dynamic & reusable dashboards with template variables that appear as dropdowns at the top of the dashboard.
- Explore Metrics: Explore your data through ad-hoc queries and dynamic drilldown. Split view and compare different time ranges, queries and data sources side by side.
- Explore Logs: Experience the magic of switching from metrics to logs with preserved label filters. Quickly search through all your logs or streaming them live.
- Alerting: Visually define alert rules for your most important metrics. Grafana will continuously evaluate and send notifications to systems like Slack, PagerDuty, VictorOps, OpsGenie.
- Mixed Data Sources: Mix different data sources in the same graph! You can specify a data source on a per-query basis. This works for even custom datasources.
Unsure if Grafana is for you? Watch Grafana in action on play.grafana.org!
The Grafana documentation is available at grafana.com/docs.
If you're interested in contributing to the Grafana project:
- Start by reading the Contributing guide.
- Learn how to set up your local environment, in our Developer guide.
- Explore our beginner-friendly issues.
- Look through our style guide and Storybook.
- Follow @grafana on Twitter.
- Read and subscribe to the Grafana blog.
- If you have a specific question, check out our discussion forums.
- For general discussions, join us on the official Slack team.
This project is tested with BrowserStack
Grafana is distributed under AGPL-3.0-only. For Apache-2.0 exceptions, see LICENSING.md.
https://www.oldliew.com/post/mac-m1%E7%BC%96%E8%AF%91grafana%E6%BA%90%E7%A0%81%E5%B9%B6%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8/ https://www.cnblogs.com/xiaoqi/p/grafana.html https://blog.csdn.net/lejun_wang1984/article/details/135430858
package main
import (
"fmt"
"net/http"
"net/http/httputil"
"net/url"
)
// GrafanaProxyHandler 代理Grafana用作管理面板
type GrafanaProxyHandler struct{}
func (h *GrafanaProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// 获取当前用户
currentUser := getCurrentUserLogin()
if currentUser == "" {
return
}
// 创建代理请求
proxyURL, err := url.Parse("http://192.168.3.8:32204/") // 替换为您的Grafana URL
proxy := httputil.NewSingleHostReverseProxy(proxyURL)
fmt.Println("err", err)
// 设置用户
r.Header.Set("Auth", currentUser)
fmt.Println(">>")
// 执行代理请求
proxy.ServeHTTP(w, r)
}
func getCurrentUserLogin() string {
// 实现获取当前用户的逻辑
// 例如:从会话中获取当前用户的登录信息
return "admin" // 这里返回示例用户
}
func main() {
handler := &GrafanaProxyHandler{}
http.Handle("/", handler)
fmt.Println("Server is running at :8080")
http.ListenAndServe(":8080", nil)
}
- grafana config
grafana.ini:
## grafana Authentication can be enabled with the following values on grafana.ini
server:
root_url: "https://grafana.powerlaw.club/grafana"
serve_from_sub_path: true
security:
allow_embedding: true
# auth.anonymous:
# enabled: true
# org_name: Main Org.
# org_role: Viewer
auth.proxy:
enabled: true
header_name: Auth
header_property: username
auto_sign_up: true
sync_ttl: 60
enable_login_token: true
- 隐藏侧边栏
# url 加 &kiosk=tv
http://127.0.0.1:8080/grafana/d/pDLS-OFSk/zhu-ji-zi-yuan-jian-kong?orgId=1&kiosk=tv