Skip to content

Commit

Permalink
add cluster to dashboard config
Browse files Browse the repository at this point in the history
  • Loading branch information
lhpqaq committed Jan 4, 2025
1 parent a44c3fd commit 7dccf77
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ providers:
},
"disableTextWrap": false,
"editorMode": "builder",
"expr": "agent_host_monitoring_cpu{cpuUsage=\"cpuUsage\"}",
"expr": "agent_host_monitoring_cpu{cpuUsage=\"cpuUsage\", <#noparse>cluster=~\"${cluster}\"</#noparse>}",
"fullMetaSearch": false,
"includeNullMetadata": true,
"legendFormat": "__auto",
Expand Down Expand Up @@ -268,7 +268,7 @@ providers:
},
"disableTextWrap": false,
"editorMode": "builder",
"expr": "agent_host_monitoring_cpu{cpuUsage=\"cpuLoadAvgMin_1\"}",
"expr": "agent_host_monitoring_cpu{cpuUsage=\"cpuLoadAvgMin_1\", <#noparse>cluster=~\"${cluster}\"</#noparse>}",
"fullMetaSearch": false,
"includeNullMetadata": true,
"legendFormat": "__auto",
Expand Down Expand Up @@ -368,7 +368,7 @@ providers:
},
"disableTextWrap": false,
"editorMode": "builder",
"expr": "agent_host_monitoring_cpu{cpuUsage=\"cpuLoadAvgMin_5\"}",
"expr": "agent_host_monitoring_cpu{cpuUsage=\"cpuLoadAvgMin_5\", <#noparse>cluster=~\"${cluster}\"</#noparse>}",
"fullMetaSearch": false,
"includeNullMetadata": true,
"legendFormat": "__auto",
Expand Down Expand Up @@ -468,7 +468,7 @@ providers:
},
"disableTextWrap": false,
"editorMode": "builder",
"expr": "agent_host_monitoring_cpu{cpuUsage=\"cpuLoadAvgMin_15\"}",
"expr": "agent_host_monitoring_cpu{cpuUsage=\"cpuLoadAvgMin_15\", <#noparse>cluster=~\"${cluster}\"</#noparse>}",
"fullMetaSearch": false,
"includeNullMetadata": true,
"legendFormat": "__auto",
Expand Down Expand Up @@ -578,7 +578,7 @@ providers:
"disableTextWrap": false,
"editorMode": "builder",
"exemplar": false,
"expr": "agent_host_monitoring_mem{memUsage=\"memTotal\"}",
"expr": "agent_host_monitoring_mem{memUsage=\"memTotal\", <#noparse>cluster=~\"${cluster}\"</#noparse>}",
"format": "time_series",
"fullMetaSearch": false,
"includeNullMetadata": true,
Expand Down Expand Up @@ -678,7 +678,7 @@ providers:
"disableTextWrap": false,
"editorMode": "builder",
"exemplar": false,
"expr": "agent_host_monitoring_mem{memUsage=\"memIdle\"}",
"expr": "agent_host_monitoring_mem{memUsage=\"memIdle\", <#noparse>cluster=~\"${cluster}\"</#noparse>}",
"format": "time_series",
"fullMetaSearch": false,
"includeNullMetadata": true,
Expand Down Expand Up @@ -791,7 +791,7 @@ providers:
{
"disableTextWrap": false,
"editorMode": "builder",
"expr": "agent_host_monitoring_diskIO",
"expr": "agent_host_monitoring_diskIO{<#noparse>cluster=~\"${cluster}\"</#noparse>}",
"fullMetaSearch": false,
"includeNullMetadata": true,
"legendFormat": "__auto",
Expand Down Expand Up @@ -887,7 +887,7 @@ providers:
{
"disableTextWrap": false,
"editorMode": "builder",
"expr": "agent_host_monitoring_disk{diskUsage=\"diskFreeSpace\"}",
"expr": "agent_host_monitoring_disk{diskUsage=\"diskFreeSpace\", <#noparse>cluster=~\"${cluster}\"</#noparse>}",
"fullMetaSearch": false,
"includeNullMetadata": true,
"legendFormat": "__auto",
Expand All @@ -904,7 +904,22 @@ providers:
"schemaVersion": 40,
"tags": [],
"templating": {
"list": []
"list": [
{
"type": "custom",
"name": "${cluster_label}",
"label": "Cluster",
"options": [],
"query": "${cluster_name}",
"refresh": 2,
"multi": false,
"includeAll": false,
"current": {
"text": "${cluster_name}",
"value": "${cluster_name}"
}
}
]
},
"time": {
"from": "now-6h",
Expand All @@ -913,7 +928,7 @@ providers:
"timepicker": {},
"timezone": "browser",
"title": "bm-agent",
"uid": "ee8r44rmotukga",
"uid": "uid4agent_dashboard",
"version": 1,
"weekStart": ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.bigtop.manager.stack.core.spi.param.Params;
import org.apache.bigtop.manager.stack.core.utils.LocalSettings;
import org.apache.bigtop.manager.stack.infra.param.InfraParams;
import org.apache.bigtop.manager.stack.infra.v1_0_0.prometheus.PrometheusParams;

import com.google.auto.service.AutoService;
import lombok.Getter;
Expand Down Expand Up @@ -70,10 +71,6 @@ public String dataDir() {
return MessageFormat.format("{0}/data", serviceHome());
}

public String confDir() {
return MessageFormat.format("{0}/conf", serviceHome());
}

public String provisioningDir() {
return MessageFormat.format("{0}/provisioning", confDir());
}
Expand Down Expand Up @@ -145,9 +142,14 @@ public void setDashboards() {
dashboards = new ArrayList<>();
for (String cluster : getClusters()) {
Map<String, Object> dashboard = new HashMap<>();
// Used for dashboard yaml configuration
dashboard.put("name", cluster);
dashboard.put("folder", cluster);
dashboard.put("path", dashboardConfigDir(cluster));

// Used for dashboard json configuration
dashboard.put("cluster_label", PrometheusParams.AGENT_TARGET_LABEL);
dashboard.put("cluster_name", cluster);
dashboards.add(dashboard);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static ShellResult config(Params params) {
user,
group,
Constants.PERMISSION_644,
grafanaParams.getGlobalParamsMap());
dashboard);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class PrometheusParams extends InfraParams {
protected final String PROMETHEUS_SELF_JOB_NAME = "prometheus";
protected final String BM_AGENT_JOB_NAME = "bm-agent";
protected final String BM_AGENT_PORT = "8081";
protected final String AGENT_TARGET_LABEL = "cluster";
public static final String AGENT_TARGET_LABEL = "cluster";

private Map<String, Object> prometheusScrapeJob;
private Map<String, Object> agentScrapeJob;
Expand Down

0 comments on commit 7dccf77

Please sign in to comment.