Skip to content

Instantly share code, notes, and snippets.

@ashutosh887
Created February 22, 2023 06:18
Show Gist options
  • Save ashutosh887/0c37508d7b81419f5d3456cff6d58001 to your computer and use it in GitHub Desktop.
Save ashutosh887/0c37508d7b81419f5d3456cff6d58001 to your computer and use it in GitHub Desktop.
Adding APM
func (hs *HTTPServer) addAPMPanelToHomeDashboard(c *models.ReqContext, dash *simplejson.Json) {
// check org if dashboard exists -> apm
// 1. if not exist in org - return
dashboardExistInOrg := true
if !dashboardExistInOrg {
return
}
// generate dashbaord
// create json and append to home json
// we can get this from UID -> getDashBoardByUID
// "datasource": {
// "type": "loki",
// "uid": "cPmWX-o4z"
panels := dash.Get("panels").MustArray()
newpanel := simplejson.NewFromAny(map[string]interface{}{
"type": "dashlist",
"id": 123123,
"gridPos": map[string]interface{}{
"x": 14,
"y": 2,
"w": 10,
"h": 14,
},
})
panels = append(panels, newpanel)
dash.Set("panels", panels)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment