-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fix dynamic JobId dimension population for AWS/EMR-Serverless in CloudWatch plugin (#104062) #105506
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
base: main
Are you sure you want to change the base?
Conversation
Serverless in CloudWatch plugin (grafana#104062) This commit resolves issue grafana#104062 by enabling dynamic population of JobId dimensions based on ApplicationId for AWS/EMRServerless metrics in the Grafana CloudWatch plugin. It also fixes a TypeScript error in FilterItem.tsx and a Prometheus metric registration panic. **Changes:** - **Backend**: - Added `handleGetDimensionValues` in `pkg/tsdb/cloudwatch/metric_find_query.go` to filter JobId by ApplicationId for AWS/EMRServerless using `ListMetrics`. - Added test in `pkg/tsdb/cloudwatch/metric_find_query_test.go` for JobId retrieval. - Removed `datasourceResponseGauge` in `pkg/infra/httpclient/httpclientprovider/datasource_metrics_middleware.go` to fix Prometheus metric conflict panic. - **Frontend**: - Modified `public/plugins/datasource/cloudwatch/MetricsQueryEditor/MetricsQueryEditor.tsx` to pass `applicationId` to `MetricStatEditor`. - Updated `public/plugins/datasource/cloudwatch/shared/MetricStatEditor.tsx` to pass `applicationId` to `Dimensions`. - Updated `public/plugins/datasource/cloudwatch/Dimensions/Dimensions.tsx` to pass `applicationId` to `FilterItem`. - Modified `public/plugins/datasource/cloudwatch/Dimensions/FilterItem.tsx` to include `applicationId` in `getDimensionValues` params for JobId queries, using type assertion due to missing `applicationId` in `datasource.ts`. **Scope:** - Limited to AWS/EMRServerless JobId queries and fixing startup panic; no impact on other functionality. **Notes:** - Type assertion in `FilterItem.tsx` is temporary; apply `datasource.ts` to remove it. - Metric fix is a workaround; consider upstream Grafana issue for proper resolution. Fixes: grafana#104062
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 2 weeks if no further activity occurs. Please feel free to give a status update or ping for review. Thank you for your contributions! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HI @Victorthedev , thanks for the pr! I was reviewing this, and did you test this? It doesn't seem like the applicationId is getting passed from the frontend to the backend at any point.
Also, could you clean up the pr a bit? it looks like the backend changes don't do anything and there are a bunch of comments and newlines that are removed that we would like to keep.
return result, nil | ||
} | ||
|
||
func (e *cloudWatchExecutor) handleGetDimensionValues(ctx context.Context, pluginCtx backend.PluginContext, parameters url.Values) ([]suggestData, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this function getting called?
}; | ||
|
||
if (namespace === 'AWS/EMRServerless' && filter.key === 'JobId' && applicationId) { | ||
(params as any).applicationId = applicationId; // Type assertion to bypass TS error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could add applicationId
to the GetDimensionValuesRequest
in resource/types.ts
and declare
const params: GetDimensionValuesRequest = {...
above to avoid using the any
} from './types'; | ||
import { CloudWatchVariableSupport } from './variables'; | ||
|
||
export interface DimensionValuesRequest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already a GetDimensionValuesRequest
in resource/types and I don't think you're using these anywhere
This commit resolves issue #104062 by enabling dynamic population of JobId dimensions based on ApplicationId for AWS/EMRServerless metrics in the Grafana CloudWatch plugin. It also fixes a TypeScript error in FilterItem.tsx and a Prometheus metric registration panic.
Changes:
handleGetDimensionValues
inpkg/tsdb/cloudwatch/metric_find_query.go
to filter JobId by ApplicationId for AWS/EMRServerless usingListMetrics
.pkg/tsdb/cloudwatch/metric_find_query_test.go
for JobId retrieval.datasourceResponseGauge
inpkg/infra/httpclient/httpclientprovider/datasource_metrics_middleware.go
to fix Prometheus metric conflict panic (see Duplicate Prometheus Metric Registration Panic for plugins_datasource_response_size #105507).public/plugins/datasource/cloudwatch/MetricsQueryEditor/MetricsQueryEditor.tsx
to passapplicationId
toMetricStatEditor
.public/plugins/datasource/cloudwatch/shared/MetricStatEditor.tsx
to passapplicationId
toDimensions
.public/plugins/datasource/cloudwatch/Dimensions/Dimensions.tsx
to passapplicationId
toFilterItem
.public/plugins/datasource/cloudwatch/Dimensions/FilterItem.tsx
to includeapplicationId
ingetDimensionValues
params for JobId queries, using type assertion due to missingapplicationId
indatasource.ts
.Scope:
Notes:
FilterItem.tsx
is temporary; applydatasource.ts
to remove it.Fixes: #104062
What is this feature?
[Add a brief description of what the feature or update does.]
Why do we need this feature?
[Add a description of the problem the feature is trying to solve.]
Who is this feature for?
[Add information on what kind of user the feature is for.]
Which issue(s) does this PR fix?:
Fixes #
Special notes for your reviewer:
Please check that: