Skip to content

Commit

Permalink
instancehealth: remove monitoring check (#920)
Browse files Browse the repository at this point in the history
Removes usage of the endpoint deprecated in https://github.com/sourcegraph/sourcegraph/pull/46299, related to sourcegraph/customer#1525
  • Loading branch information
bobheadxi authored Jan 12, 2023
1 parent 6d72b3f commit 90bd461
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions internal/instancehealth/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package instancehealth

import (
"fmt"
"strings"
"time"

"github.com/sourcegraph/sourcegraph/lib/errors"
Expand Down Expand Up @@ -31,11 +30,6 @@ func NewChecks(
defer b.Close()
return checkSiteConfiguration(b, instanceHealth)
},
func(out *output.Output) error {
b := out.Block(output.Styled(output.StyleBold, "Monitoring alerts"))
defer b.Close()
return checkMonitoringAlerts(b, since, instanceHealth)
},
func(out *output.Output) error {
b := out.Block(output.Styled(output.StyleBold, "External services"))
defer b.Close()
Expand Down Expand Up @@ -86,33 +80,6 @@ func checkSiteConfiguration(
return nil
}

// checkMonitoringAlerts indicates if there are any alerts issued by monitoring infra
func checkMonitoringAlerts(
out output.Writer,
since time.Duration,
instanceHealth Indicators,
) error {
var criticalAlerts int
for _, a := range instanceHealth.Site.MonitoringStatistics.Alerts {
if a.Average == 0 || !strings.Contains(strings.ToLower(a.Name), "critical") {
continue
}
// average is ratio of 12h windows that alert was active, so we set the threshold
// if it's possible this alert could have been active in this 'since' window.
if a.Average*0.5 >= since.Hours()/12 {
criticalAlerts += 1
out.WriteLine(output.Linef(output.EmojiWarning, output.StyleWarning,
"Found recently active alert: %q", a.Name))
}
}
if criticalAlerts == 0 {
out.WriteLine(output.Emoji(output.EmojiSuccess, "No critical monitoring alerts!"))
}
// never error, just issue printed warning, since critical alerts aren't all _that_
// reliable today, though they provide a potentially useful signal.
return nil
}

// checkExternalServices checks the health of external service syncing
func checkExternalServices(
out output.Writer,
Expand Down

0 comments on commit 90bd461

Please sign in to comment.