Skip to content

Commit

Permalink
Add Hive rest config and ClusterManager to monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
kimorris27 authored and rhamitarora committed Jan 21, 2025
1 parent af250d5 commit 05a6fe2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
30 changes: 18 additions & 12 deletions pkg/monitor/cluster/clustersync.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

func (mon *Monitor) emitClusterSync(ctx context.Context) error {
if mon.hiveClusterManager == nil {
// TODO(hive): remove this once we have Hive everywhere
// TODO(hive): remove this once we have Hive everywhere.
mon.log.Info("skipping: no hive cluster manager")
return nil
}
Expand All @@ -21,18 +21,22 @@ func (mon *Monitor) emitClusterSync(ctx context.Context) error {
if err != nil {
return err
}
if clusterSync != nil {
if clusterSync.Status.SyncSets != nil {
if clusterSync == nil {
return nil
} else {
if clusterSync.Status.SyncSets == nil {
return nil
} else {
for _, s := range clusterSync.Status.SyncSets {
mon.emitGauge("hive.clustersync", 1, map[string]string{
"metric": "SyncSets",
"name": s.Name,
"result": string(s.Result),
"syncType": "SyncSets",
"name": s.Name,
"result": string(s.Result),
})

if mon.hourlyRun {
mon.log.WithFields(logrus.Fields{
"metric": "SyncSets",
"syncType": "SyncSets",
"name": s.Name,
"result": string(s.Result),
"firstSuccessTime": timeToString(s.FirstSuccessTime),
Expand All @@ -42,16 +46,18 @@ func (mon *Monitor) emitClusterSync(ctx context.Context) error {
}
}
}
if clusterSync.Status.SelectorSyncSets != nil {
if clusterSync.Status.SelectorSyncSets == nil {
return nil
} else {
for _, s := range clusterSync.Status.SelectorSyncSets {
mon.emitGauge("hive.clustersync", 1, map[string]string{
"metric": "SelectorSyncSets",
"name": s.Name,
"result": string(s.Result),
"syncType": "SelectorSyncSets",
"name": s.Name,
"result": string(s.Result),
})
if mon.hourlyRun {
mon.log.WithFields(logrus.Fields{
"metric": "SelectorSyncSets",
"syncType": "SelectorSyncSets",
"name": s.Name,
"result": string(s.Result),
"firstSuccessTime": timeToString(s.FirstSuccessTime),
Expand Down
24 changes: 12 additions & 12 deletions pkg/monitor/cluster/clustersync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ func TestEmitClusterSync(t *testing.T) {
name: "hive.clustersync",
value: 1,
labels: map[string]string{
"metric": "SyncSets",
"name": "syncset1",
"result": "Success",
"syncType": "SyncSets",
"name": "syncset1",
"result": "Success",
},
},
{
name: "hive.clustersync",
value: 1,
labels: map[string]string{
"metric": "SelectorSyncSets",
"name": "selectorsyncset1",
"result": "Success",
"syncType": "SelectorSyncSets",
"name": "selectorsyncset1",
"result": "Success",
},
},
},
Expand Down Expand Up @@ -126,18 +126,18 @@ func TestEmitClusterSync(t *testing.T) {
name: "hive.clustersync",
value: 1,
labels: map[string]string{
"metric": "SyncSets",
"name": "syncset2",
"result": "Failure",
"syncType": "SyncSets",
"name": "syncset2",
"result": "Failure",
},
},
{
name: "hive.clustersync",
value: 1,
labels: map[string]string{
"metric": "SelectorSyncSets",
"name": "selectorsyncset2",
"result": "Success",
"syncType": "SelectorSyncSets",
"name": "selectorsyncset2",
"result": "Success",
},
},
},
Expand Down

0 comments on commit 05a6fe2

Please sign in to comment.