Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge chore: Added more important instance statuses #238

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configs/grafana/common.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local options = link.dashboards.options;
transparent: 'transparent',
default: 'white',
ok: 'green',
info: 'blue',
notice: 'yellow',
warning: 'orange',
danger: 'red',
Expand Down
40 changes: 28 additions & 12 deletions configs/grafana/panels/instance.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,19 @@ local colors = common.colors;
+ standardOptions.withMappings([
standardOptions.mapping.ValueMap.withType('value')
+ standardOptions.mapping.ValueMap.withOptions({
'-1': { index: 0, color: 'purple', text: 'Unknown' },
'0': { index: 1, color: colors.danger, text: 'Stopped' },
'1': { index: 2, color: colors.ok, text: 'Available' },
'2': { index: 3, color: colors.notice, text: 'Backing-up' },
'-8': { index: 0, color: colors.info, text: 'Upgrading' },
'-7': { index: 1, color: colors.danger, text: 'Storage-full' },
'-6': { index: 2, color: colors.danger, text: 'Failed' },
'-5': { index: 3, color: colors.warning, text: 'Rebooting' },
'-4': { index: 4, color: colors.danger, text: 'Deleting' },
'-3': { index: 5, color: colors.notice, text: 'Creating' },
'-2': { index: 6, color: colors.notice, text: 'Stopping' },
'-1': { index: 7, color: 'purple', text: 'Unknown' },
'0': { index: 8, color: colors.danger, text: 'Stopped' },
'1': { index: 9, color: colors.ok, text: 'Available' },
'2': { index: 10, color: colors.notice, text: 'Backing-up' },
'3': { index: 11, color: colors.ok, text: 'Starting' },
'4': { index: 12, color: colors.info, text: 'Modifying' },
}),
]),
},
Expand Down Expand Up @@ -386,13 +395,13 @@ local colors = common.colors;
fieldOverride.byName.new('Replication slots')
+ standardOptions.override.byType.withPropertiesFromOptions(
color.withMode('fixed')
+ color.withFixedColor('blue')
+ color.withFixedColor(colors.info)
+ custom.stacking.withMode('normal')
),
fieldOverride.byName.new('Other')
+ standardOptions.override.byType.withPropertiesFromOptions(
color.withMode('fixed')
+ color.withFixedColor('orange')
+ color.withFixedColor(colors.warning)
+ custom.stacking.withMode('normal')
),
fieldOverride.byName.new('Used')
Expand Down Expand Up @@ -455,12 +464,19 @@ local colors = common.colors;
+ standardOptions.withMappings([
standardOptions.mapping.ValueMap.withType('value')
+ standardOptions.mapping.ValueMap.withOptions({
'-2': { index: -2, color: colors.warning, text: 'Stopping' },
'-1': { index: -1, color: colors.notice, text: 'Unknown' },
'0': { index: -1, color: colors.warning, text: 'Stopped' },
'1': { index: -1, color: colors.ok, text: 'Available' },
'2': { index: -1, color: colors.notice, text: 'Backing-up' },
'3': { index: -1, color: colors.warning, text: 'Starting' },
'-8': { index: 0, color: colors.info, text: 'Upgrading' },
'-7': { index: 1, color: colors.danger, text: 'Storage-full' },
'-6': { index: 2, color: colors.danger, text: 'Failed' },
'-5': { index: 3, color: colors.warning, text: 'Rebooting' },
'-4': { index: 4, color: colors.danger, text: 'Deleting' },
'-3': { index: 5, color: colors.notice, text: 'Creating' },
'-2': { index: 6, color: colors.notice, text: 'Stopping' },
'-1': { index: 7, color: 'purple', text: 'Unknown' },
'0': { index: 8, color: colors.danger, text: 'Stopped' },
'1': { index: 9, color: colors.ok, text: 'Available' },
'2': { index: 10, color: colors.notice, text: 'Backing-up' },
'3': { index: 11, color: colors.ok, text: 'Starting' },
'4': { index: 12, color: colors.info, text: 'Modifying' },
}),
])
+ standardOptions.withMin(null)
Expand Down
26 changes: 17 additions & 9 deletions internal/app/rds/rds.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ const (
InstanceStatusStopping int = -2
InstanceStatusCreating int = -3
InstanceStatusDeleting int = -4
InstanceStatusRebooting int = -5
InstanceStatusFailed int = -6
InstanceStatusStorageFull int = -7
InstanceStatusUpgrading int = -8
NoPendingMaintenanceOperation string = "no"
UnknownMaintenanceOperation string = "unknown"
UnscheduledPendingMaintenanceOperation string = "pending"
Expand Down Expand Up @@ -97,15 +101,19 @@ const (
var tracer = otel.Tracer("github/qonto/prometheus-rds-exporter/internal/app/rds")

var instanceStatuses = map[string]int{
"available": InstanceStatusAvailable,
"backing-up": InstanceStatusBackingUp,
"creating": InstanceStatusCreating,
"deleting": InstanceStatusDeleting,
"modifying": InstanceStatusModifying,
"starting": InstanceStatusStarting,
"stopped": InstanceStatusStopped,
"stopping": InstanceStatusStopping,
"unknown": InstanceStatusUnknown,
"available": InstanceStatusAvailable,
"backing-up": InstanceStatusBackingUp,
"creating": InstanceStatusCreating,
"deleting": InstanceStatusDeleting,
"failed": InstanceStatusFailed,
"modifying": InstanceStatusModifying,
"rebooting": InstanceStatusRebooting,
"starting": InstanceStatusStarting,
"stopped": InstanceStatusStopped,
"storage-full": InstanceStatusStorageFull,
"stopping": InstanceStatusStopping,
"unknown": InstanceStatusUnknown,
"upgrading": InstanceStatusUpgrading,
}

type RDSClient interface {
Expand Down
4 changes: 4 additions & 0 deletions internal/app/rds/rds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,15 @@ func TestGetDBInstanceStatusCode(t *testing.T) {
{input: "backing-up", want: rds.InstanceStatusBackingUp},
{input: "creating", want: rds.InstanceStatusCreating},
{input: "deleting", want: rds.InstanceStatusDeleting},
{input: "failed", want: rds.InstanceStatusFailed},
{input: "future", want: rds.InstanceStatusUnknown},
{input: "modifying", want: rds.InstanceStatusModifying},
{input: "stopped", want: rds.InstanceStatusStopped},
{input: "stopping", want: rds.InstanceStatusStopping},
{input: "storage-full", want: rds.InstanceStatusStorageFull},
{input: "rebooting", want: rds.InstanceStatusRebooting},
{input: "unknown", want: rds.InstanceStatusUnknown},
{input: "upgrading", want: rds.InstanceStatusUpgrading},
}

for _, tc := range tests {
Expand Down
Loading