-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add prometheus alerts in support bundle
Signed-off-by: Jack Yu <jack.yu@suse.com>
- Loading branch information
Showing
10 changed files
with
1,397 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package utils | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/prometheus/client_golang/api" | ||
"github.com/prometheus/client_golang/api/prometheus/v1" | ||
) | ||
|
||
const PrometheusPort = 9090 | ||
|
||
type Prometheus struct { | ||
api v1.API | ||
} | ||
|
||
func NewPrometheus(host string) (*Prometheus, error) { | ||
client, err := api.NewClient(api.Config{ | ||
Address: fmt.Sprintf("http://%s:%d", host, PrometheusPort), | ||
}) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &Prometheus{api: v1.NewAPI(client)}, nil | ||
} | ||
|
||
func (p *Prometheus) GetAlerts(ctx context.Context) ([]v1.Alert, error) { | ||
result, err := p.api.Alerts(ctx) | ||
|
||
if err != nil { | ||
return []v1.Alert{}, err | ||
} | ||
|
||
return result.Alerts, nil | ||
} |
131 changes: 131 additions & 0 deletions
131
vendor/github.com/prometheus/client_golang/api/client.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.