So, it’s a mixed query between prometheus (custom Gauge) and Cloudwatch (S3)
Prometheus looks like this (not sure if this is enough as I did not find a better way to share the query
“schema”: {
“refId”: “xchange_status”,
“meta”: {
“type”: “numeric-multi”,
“typeVersion”: [
0,
1
],
“custom”: {
“resultType”: “vector”
},
“executedQueryString”: “Expr: xchange_bucket\nStep: 2m0s”,
“preferredVisualisationType”: “rawPrometheus”
},
“fields”: [
{
“name”: “Time”,
“type”: “time”,
“config”: {
“interval”: 120000
}
},
{
“name”: “name”,
“config”: {
“filterable”: true
},
“type”: “string”
},
{
“name”: “BucketName”,
“config”: {
“filterable”: true
},
“type”: “string”
},
{
“name”: “expiration_date”,
“config”: {
“filterable”: true
},
“type”: “string”
},
{
“name”: “expired”,
“config”: {
“filterable”: true
},
“type”: “string”
},
{
“name”: “instance”,
“config”: {
“filterable”: true
},
“type”: “string”
},
{
“name”: “job”,
“config”: {
“filterable”: true
},
“type”: “string”
},
{
“name”: “legacy”,
“config”: {
“filterable”: true
},
“type”: “string”
},
{
“name”: “requestor”,
“config”: {
“filterable”: true
},
“type”: “string”
},
{
“name”: “Value”,
“type”: “number”,
“config”: {}
}
]
}
and produces output like this (CSV) (single row):
Time, name, BucketName, expiration_date, expired, instance, job, legacy, requestor, Value
33:41.2, xchange_bucket, bi-bio-name-xchange, 2024-01-01T00:00:00Z, TRUE, servername.eu.domain.com, integrations/unix, 1, name@domain.com, -438
so, with this first query I get all Bucket tags, and I’m interested in BucketName and expired. This is the info I’d like to “join” to my second query.
The second query is cloudwatch and looks like this:
REMOVE_EMPTY(SEARCH(‘{“AWS/S3”,“BucketName”,“StorageType”} MetricName=“BucketSizeBytes” :aws.AccountId=“512XXXXX5801”’, ‘Average’, 10800))
and produces output like this (CSV):
Time, {“bucket”:“51XXXX01-terraform-state-bucket StandardStorage”}
15/03/2025 23:38, 161021
In some case, when the bucket is stored in 2 different sotrgae types, I get entries like
> Time, |
{bucket:51XXXX01-terraform-state-bucket StandardStorage} |
15/03/2025 23:38, |
161021 |
> Time, |
{bucket:51XXXX01-terraform-state-bucket StandardIAStorage} |
— |
— |
15/03/2025 23:38, |
317021 |
So, for the same bucket I get two entries based on the Storage type.
(this is just ane example)
I’d say transformations themselves are not that relevant as I only have “labels to fields” to get a “BucketName” filed; something like:
Time, 51XXXX01-terraform-state-bucket, BucketName, Series
15/03/2025 23:38 , 161021, 51XXXX01-terraform-state-bucket, bi-bio-abiosciences-xchange StandardIAStorage
Now, if I go for the join based on BucketName, I get something like this (and sorry here cause I do not really know how to show this aprt from this screenshot:

and continues like this:

so, as you can see, the merge works, but the value is still the value from the first query and not the size of each bucket in each storage type. The table itself become really complex to manage and now merging values from the two fields it’s almost impossible as every bucket has the value under a differnet column name.
Not sure if I’m doing something wrong or that my approach is, simply, wrong (based on the result and the complexity I see on the produced table) and there’s a simplest wy to embbed this “expired” tag information to the bucket in a different way.
thanks