[refactor] Add monitorName parameter to history data query for consistent app handling#3994
[refactor] Add monitorName parameter to history data query for consistent app handling#3994Saramanda9988 wants to merge 4 commits intoapache:masterfrom
Conversation
| this.loading = `${this.i18nSvc.fanyi('monitor.detail.chart.data-loading')}`; | ||
| let metricData$ = this.monitorSvc | ||
| .getMonitorMetricHistoryData(this.instance, this.app, this.metrics, this.metric, this.timePeriod, isInterval) | ||
| .getMonitorMetricHistoryData(this.instance, this.monitorName, this.app, this.metrics, this.metric, this.timePeriod, isInterval) |
There was a problem hiding this comment.
Can we just directly convert the app here? That way, we won't need to adjust the REST API.
There was a problem hiding this comment.
hi,thanks for your cr.
Do you mean we should modify the app parameter directly in the fe? Maybe that would require adjusting greptimedb and vm to align with other tsdbs.
Just concerned this adds complexity to these two storages that we'll support long-term. What do you think?
There was a problem hiding this comment.
Thanks for your reply.
- VictoriaMetricsClusterDataStorage And VictoriaMetricsDataStorage
// saveData() method
if (metricsData.getApp().startsWith(CommonConstants.PROMETHEUS_APP_PREFIX)) {
isPrometheusAuto = true;
}
// getHistoryMetricData()
String labelName = metrics + SPILT + metric;
if (CommonConstants.PROMETHEUS.equals(app)) { // app.startsWith(CommonConstants.PROMETHEUS_APP_PREFIX)
labelName = metrics;
}
String timeSeriesSelector = Stream.of(
LABEL_KEY_NAME + "=\"" + labelName + "\"",
LABEL_KEY_INSTANCE + "=\"" + instance + "\"",
CommonConstants.PROMETHEUS.equals(app) ? null : MONITOR_METRIC_KEY + "=\"" + metric + "\"" // app.startsWith(CommonConstants.PROMETHEUS_APP_PREFIX)
).filter(Objects::nonNull).collect(Collectors.joining(","));
- GreptimeDbDataStorage: getHistoryMetricData() and getHistoryIntervalMetricData()
if (!CommonConstants.PROMETHEUS.equals(app)) { // default : String timeSeriesSelector = LABEL_KEY_NAME + "=\"" + name + "\"" + "," + LABEL_KEY_INSTANCE + "=\"" + instance + "\"";
timeSeriesSelector = timeSeriesSelector + "," + LABEL_KEY_FIELD + "=\"" + metric + "\"";
}
Theoretically, only the VM needs to be modified, right? And since the VM is saved through its mapping, maintaining consistency shouldn't be an issue. What do you think?
There was a problem hiding this comment.
@Duansg , hi thanks for your reply
Yes, you're right. Let's do it this way.
I'll close this PR and submit a new one following your suggestion; it will be much simpler.
| @ToolParam(description = "Time range (e.g., '1h', '6h', '24h', '7d')", required = false) String history, | ||
| @ToolParam(description = "Whether to aggregate data with intervals", required = false) Boolean interval) { | ||
| @ToolParam(description = "Instance identifier (e.g., 'ip:port', 'ip', or 'domain')") String instance, | ||
| @ToolParam(description = "Monitor name for querying historical metrics") String monitorName, |
There was a problem hiding this comment.
Should monitorName be exposed to the Tool? I believe this is an unstable parameter and doesn't need to be exposed externally. It should remain within the internal normalization layer. I recommend performing app conversion internally.
What's changed?
please refer to #3983
In the method of querying historical data, add the
monitorNameparameter. When the app is prometheus, automatically concatenate the prefix prometheus{monitorName} to ensure that the query and storage use the same app valueIotDb
Influxdb
QuestDb
TDengine
Checklist
Add or update API