Closed MartinRoman7 closed 1 year ago
I'm not 100% sure what you are asking, but it did bring to my attention that the docs for the CloudWatch datasource are empty, which indicates the code isn't there either. I'll have a look at that.
Hi, Duologic!
Basically, I would like to know if you have an example using grafonnet.query.cloudwatch
.
And also, I'm using an old Grafonnet version, the way to add a new target is by using the following code:
.addTargets(
[
cloudwatch.target(
region='$region',
namespace='AWS/RDS',
metric=metric_one,
datasource='$datasource',
statistic=statistic_one,
dimensions={ DBInstanceIdentifier: '$dbName' }
)
]
I would like to know if there is a way to translate the old cloudwatch.target
schema to the new grafonnet.query.cloudwatch
for all the variables.
Thanks!
The docs now include the Cloudwatch query: https://grafana.github.io/grafonnet/grafonnet/query/cloudWatch.html
I believe your example should look something like this (I have not tested this and I also don't know anything about cloudwatch):
local grafonnet = import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet';
local cloudwatch = grafonnet.query.cloudWatch.CloudWatchMetricsQuery;
cloudwatch.withRegion('$region')
+ cloudwatch.withNamespace('AWS/RDS')
+ cloudwatch.withMetricName(metric_one)
+ cloudwatch.withDatasource('$datasource')
+ cloudwatch.withStatistics([statistic_one])
+ cloudwatch.withDimensions({ DBInstanceIdentifier: '$dbName' })
I found another way by using the fn .withTargets(targets)
in the panel. I created a new file, targets.libsonnet
:
// target example
cpuUtilization(metric,statistic):
{
'datasource': '$' + variables.name.name,
'dimensions': {
'DBInstanceIdentifier': '$' + variables.name.name
},
'highResolution': false,
'metricName': metric,
'namespace': 'AWS/RDS',
'period': 'auto',
'refId': 'A',
'region': '$' + variables.region.name,
'statistics': [
statistic
]
},
And then importing the targets.libsonnet
in the panels.libsonnet
file
Thank you for your help. I really appreciate it!
Hello team!
I'm using the new Grafonnet version (9.4.0), and I identified that adding a new target in the panel is different compared with the old version. In the oldest Grafonnet version, the way that I followed to add a new target in the panel was by using the following function:
But in the new Grafonnet version (9.4.0), I found that it is necessary to use the
grafonnet.query.cloudwatch
subpackage to write a query. In the examples folder, I see agrafonnet.query.prometheus
example:Do you know if there is a way to "translate" the Builder configuration to a Code option to use the query subpackage?
Also, if you have an example using
grafonnet.query.cloudwatch
would be a great help.Thanks in advance!