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

feat: select db instances by tags #232

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

msvticket
Copy link

fixes #94

@msvticket msvticket force-pushed the tagselection branch 3 times, most recently from 428937a to 1ff1103 Compare November 29, 2024 21:45
@msvticket msvticket marked this pull request as ready for review November 29, 2024 22:44
@msvticket msvticket force-pushed the tagselection branch 2 times, most recently from 3a9c673 to cff32d0 Compare December 2, 2024 11:15
@msvticket
Copy link
Author

I thought I was basically finished with this PR, but during testing I realised serious limitations in tag selection since configuration of prometheus-rds-exporter is done using viper which isn't case sensitive: spf13/viper#1014

This means that you can only select tags where keys and values are lower case, which isn't a convention most use.

I don't see how to get around this issue while keeping viper. Maybe switch to koanf?

@msvticket msvticket force-pushed the tagselection branch 3 times, most recently from d30e1d3 to f3c1a27 Compare December 2, 2024 22:54
@msvticket
Copy link
Author

So, that's what I did: switched to koanf for configuration

@msvticket
Copy link
Author

@dcupif @qfritz Can this be reviewed please?

@qfritz
Copy link
Contributor

qfritz commented Dec 3, 2024

We'll have a look. 👀
Thanks for this feature!

@msvticket
Copy link
Author

I now realised that so far I haven't implemented any limitation of which metrics are fetched from CloudWatch. I can look into that if you like.

@msvticket
Copy link
Author

Ah, it's only the rds_usage_* series that are fetched as the sum for all instances. But I don't think they can be fetched from CloudWatch any other way, so I think it's fine.

Copy link

@jbourdale jbourdale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @msvticket.
Thanks for this contribution! This feature is definitely needed!
I've added some recommendations as comment

internal/app/rds/rds.go Outdated Show resolved Hide resolved
@@ -335,7 +336,7 @@ func TestInstanceAge(t *testing.T) {
ctx := context.TODO()
client := mock.RDSClient{DescribeDBInstancesOutput: mockDescribeDBInstancesOutput}
configuration := rds.Configuration{}
fetcher := rds.NewFetcher(ctx, client, configuration)
fetcher := rds.NewFetcher(ctx, client, nil, slog.Logger{}, configuration)
metrics, err := fetcher.GetInstancesMetrics()

expectedAge := time.Since(*rdsInstance.InstanceCreateTime)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test case for tag selection please?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would I test? The selection of resources based on tags are made at AWS...

README.md Outdated Show resolved Hide resolved
mostly to get around spf13/viper#1014

Signed-off-by: Mårten Svantesson <[email protected]>
Signed-off-by: Mårten Svantesson <[email protected]>
needed for more complex configuration, i.e. tag-selections

Signed-off-by: Mårten Svantesson <[email protected]>
Signed-off-by: Mårten Svantesson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow restricting exporter scope to specific instances
3 participants