GetRules implements Client
(ctx context.Context, since userconfig.ID)
| 90 | |
| 91 | // GetRules implements Client |
| 92 | func (c ConfigDBClient) GetRules(ctx context.Context, since userconfig.ID) (map[string]userconfig.VersionedRulesConfig, error) { |
| 93 | suffix := "" |
| 94 | if since != 0 { |
| 95 | suffix = fmt.Sprintf("?since=%d", since) |
| 96 | } |
| 97 | endpoint := fmt.Sprintf("%s/private/api/prom/configs/rules%s", c.URL.String(), suffix) |
| 98 | var response *ConfigsResponse |
| 99 | err := instrument.CollectedRequest(ctx, "GetRules", configsRequestDuration, instrument.ErrorCode, func(ctx context.Context) error { |
| 100 | var err error |
| 101 | response, err = doRequest(endpoint, c.Timeout, c.TLSConfig, since) |
| 102 | return err |
| 103 | }) |
| 104 | if err != nil { |
| 105 | return nil, err |
| 106 | } |
| 107 | configs := map[string]userconfig.VersionedRulesConfig{} |
| 108 | for id, view := range response.Configs { |
| 109 | cfg := view.GetVersionedRulesConfig() |
| 110 | if cfg != nil { |
| 111 | configs[id] = *cfg |
| 112 | } |
| 113 | } |
| 114 | return configs, nil |
| 115 | } |
| 116 | |
| 117 | // GetAlerts implements Client. |
| 118 | func (c ConfigDBClient) GetAlerts(ctx context.Context, since userconfig.ID) (*ConfigsResponse, error) { |
nothing calls this directly
no test coverage detected