Skip to content

[BUG] Prometheus monitor history data query fails due to 'app' parameter inconsistency in some storages #3983

@Saramanda9988

Description

@Saramanda9988

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When querying historical metrics data for a Prometheus-type monitor, the query returns empty results even though the data has been successfully stored. Consequently, historical data charts display "No Data."

Image

The issue stems from an inconsistency in the app parameter value between the storage and query phases for Prometheus monitors.

Expected Behavior

No response

Steps To Reproduce

No response

Environment

HertzBeat version(s):1.8.0

Debug logs

No response

Anything else?

At Storage (Monitor Creation/Modification): In MonitorServiceImpl.java:

if (CommonConstants.PROMETHEUS.equals(monitor.getApp())) {
    appDefine.setApp(CommonConstants.PROMETHEUS_APP_PREFIX + monitor.getName());
}

For Prometheus monitors, AppDefine.app is set to prometheus_{monitorName} (e.g., prometheus_my_monitor). This value is used to construct table names in storage engines.

Image

At Storage Execution (using TdEngine as an example):

  • String app = metricsData.getApp() (retrieves the prefixed name from AppDefine).
  • Table name becomes app + "_" + metrics + "_" + instance + "_v2", resulting in prometheus_my_monitor_metrics_instance_v2.
Image

At Query (Frontend to Controller):

  • The frontend passes the app parameter from Monitor.getApp(), which is simply prometheus.
  • MetricsDataController.java: Extracts app = names[0] (resulting in prometheus).
Image

When the query reaches the storage layer (e.g., TdEngineDataStorage.java:360), getTable(app, metrics, instance) uses the raw prometheus string instead of the prefixed prometheus_my_monitor, failing to locate the correct table.

The following storages construct table names using the app parameter and are affected:
TDengine (TdEngineDataStorage.java)
IoTDB (IotDbDataStorage.java)
InfluxDB (InfluxdbDataStorage.java)
QuestDB (QuestdbDataStorage.java)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

To do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions