(wheres []monitor.MonWhereItem)
| 68 | } |
| 69 | |
| 70 | func formatFilter(wheres []monitor.MonWhereItem) string { |
| 71 | filter := `` |
| 72 | if len(wheres) > 0 { |
| 73 | filters := make([]string, 0, len(wheres)) |
| 74 | for _, where := range wheres { |
| 75 | if len(where.Values) > 0 { |
| 76 | wl := make([]string, 0, len(where.Values)) |
| 77 | for _, v := range where.Values { |
| 78 | wl = append(wl, fmt.Sprintf(fmt.Sprintf(`r["%s"] == "%s"`, where.Key, v))) |
| 79 | } |
| 80 | filters = append(filters, fmt.Sprint("(", strings.Join(wl, " or "), ")")) |
| 81 | } |
| 82 | } |
| 83 | filter = fmt.Sprint(`|> filter(fn:(r)=>`, strings.Join(filters, " and "), ")") |
| 84 | } |
| 85 | return filter |
| 86 | } |
| 87 | |
| 88 | // getTimeIntervalAndBucket 根据start和end来获取窗口时间间隔,窗口偏移量offset,以及使用的bucket, 查询的startTime也会格式化 |
| 89 | func getTimeIntervalAndBucket(startTime, endTime time.Time) (time.Time, string, string, string) { |
no outgoing calls
no test coverage detected