mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'master' of github.com:grafana/grafana into develop
This commit is contained in:
@@ -22,6 +22,7 @@ func GetAnnotations(c *middleware.Context) Response {
|
||||
PanelId: c.QueryInt64("panelId"),
|
||||
Limit: c.QueryInt64("limit"),
|
||||
Tags: c.QueryStrings("tags"),
|
||||
Type: c.Query("type"),
|
||||
}
|
||||
|
||||
repo := annotations.GetRepository()
|
||||
|
||||
@@ -194,7 +194,8 @@ func (hs *HttpServer) metricsEndpoint(ctx *macaron.Context) {
|
||||
}
|
||||
|
||||
func (hs *HttpServer) healthHandler(ctx *macaron.Context) {
|
||||
if ctx.Req.Method != "GET" || ctx.Req.URL.Path != "/api/health" {
|
||||
notHeadOrGet := ctx.Req.Method != http.MethodGet && ctx.Req.Method != http.MethodHead
|
||||
if notHeadOrGet || ctx.Req.URL.Path != "/api/health" {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ type ItemQuery struct {
|
||||
DashboardId int64 `json:"dashboardId"`
|
||||
PanelId int64 `json:"panelId"`
|
||||
Tags []string `json:"tags"`
|
||||
Type string `json:"type"`
|
||||
|
||||
Limit int64 `json:"limit"`
|
||||
}
|
||||
|
||||
@@ -158,6 +158,10 @@ func (r *SqlAnnotationRepo) Find(query *annotations.ItemQuery) ([]*annotations.I
|
||||
params = append(params, query.From, query.To)
|
||||
}
|
||||
|
||||
if query.Type == "alert" {
|
||||
sql.WriteString(` AND annotation.alert_id > 0`)
|
||||
}
|
||||
|
||||
if len(query.Tags) > 0 {
|
||||
keyValueFilters := []string{}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ func TestAnnotations(t *testing.T) {
|
||||
UserId: 1,
|
||||
DashboardId: 1,
|
||||
Text: "hello",
|
||||
Type: "alert",
|
||||
Epoch: 10,
|
||||
Tags: []string{"outage", "error", "type:outage", "server:server-1"},
|
||||
}
|
||||
@@ -91,6 +92,19 @@ func TestAnnotations(t *testing.T) {
|
||||
So(items, ShouldHaveLength, 0)
|
||||
})
|
||||
|
||||
Convey("Should not find one when type filter does not match", func() {
|
||||
items, err := repo.Find(&annotations.ItemQuery{
|
||||
OrgId: 1,
|
||||
DashboardId: 1,
|
||||
From: 1,
|
||||
To: 15,
|
||||
Type: "alert",
|
||||
})
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
So(items, ShouldHaveLength, 0)
|
||||
})
|
||||
|
||||
Convey("Should find one when all tag filters does match", func() {
|
||||
items, err := repo.Find(&annotations.ItemQuery{
|
||||
OrgId: 1,
|
||||
|
||||
@@ -35,7 +35,7 @@ func NewMysqlQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndpoin
|
||||
MacroEngine: NewMysqlMacroEngine(),
|
||||
}
|
||||
|
||||
cnnstr := fmt.Sprintf("%s:%s@%s(%s)/%s?collation=utf8mb4_unicode_ci&parseTime=true&loc=UTC",
|
||||
cnnstr := fmt.Sprintf("%s:%s@%s(%s)/%s?collation=utf8mb4_unicode_ci&parseTime=true&loc=UTC&allowNativePasswords=true",
|
||||
datasource.User,
|
||||
datasource.Password,
|
||||
"tcp",
|
||||
|
||||
Reference in New Issue
Block a user