-
Notifications
You must be signed in to change notification settings - Fork 53
/
test_plugin.go
66 lines (58 loc) · 2.39 KB
/
test_plugin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package test
import (
"time"
alertingv1 "github.com/rancher/opni/pkg/apis/alerting/v1"
v1 "github.com/rancher/opni/pkg/apis/alerting/v1"
corev1 "github.com/rancher/opni/pkg/apis/core/v1"
"github.com/rancher/opni/pkg/plugins/meta"
"github.com/rancher/opni/pkg/test"
"github.com/rancher/opni/plugins/alerting/pkg/agent"
"github.com/rancher/opni/plugins/alerting/pkg/alerting"
"github.com/rancher/opni/plugins/alerting/pkg/alerting/alarms/v1"
endpointv1 "github.com/rancher/opni/plugins/alerting/pkg/alerting/endpoints/v1"
"google.golang.org/protobuf/types/known/durationpb"
)
func init() {
test.EnablePlugin(meta.ModeGateway, alerting.Scheme)
alerting.DefaultDisconnectAlarm = func(clusterId string) *v1.AlertCondition {
return &alertingv1.AlertCondition{
Name: "agent-disconnect",
Description: "Alert when the downstream agent disconnects from the opni upstream",
Labels: []string{"agent-disconnect", "opni", "_default"},
Severity: alertingv1.OpniSeverity_Critical,
AlertType: &alertingv1.AlertTypeDetails{
Type: &alertingv1.AlertTypeDetails_System{
System: &alertingv1.AlertConditionSystem{
ClusterId: &corev1.Reference{Id: clusterId},
Timeout: durationpb.New(1 * time.Second),
},
},
},
}
}
alerting.DefaultCapabilityHealthAlarm = func(clusterId string) *v1.AlertCondition {
return &alertingv1.AlertCondition{
Name: "agent-capability-unhealthy",
Description: "Alert when some downstream agent capability becomes unhealthy",
Labels: []string{"agent-capability-health", "opni", "_default"},
Severity: alertingv1.OpniSeverity_Critical,
AlertType: &alertingv1.AlertTypeDetails{
Type: &alertingv1.AlertTypeDetails_DownstreamCapability{
DownstreamCapability: &alertingv1.AlertConditionDownstreamCapability{
ClusterId: &corev1.Reference{Id: clusterId},
CapabilityState: alerting.ListBadDefaultStatuses(),
For: durationpb.New(1 * time.Second),
},
},
},
}
}
alerting.SyncInterval = time.Second * 1
alerting.ForceSyncInterval = time.Second * 60
alarms.DisconnectStreamEvaluateInterval = time.Second * 1
alarms.CapabilityStreamEvaluateInterval = time.Minute * 100
alarms.CortexStreamEvaluateInterval = time.Second * 1
test.EnablePlugin(meta.ModeAgent, agent.Scheme)
endpointv1.RetryTestEdnpoint = time.Millisecond * 50
agent.RuleSyncInterval = time.Second * 1
}