diff options
| author | zhangshuai <[email protected]> | 2024-05-16 15:02:06 +0800 |
|---|---|---|
| committer | zhangshuai <[email protected]> | 2024-05-16 15:02:06 +0800 |
| commit | 767010e95abefad0a28aa941f5af07717d8f408a (patch) | |
| tree | ff2e5badbf6eca0405adfe9127b77aaac6b9c7cd | |
| parent | 4010851a0fb300e03e5beaf8541972374e0f9e99 (diff) | |
fix:修复 prom_yml_tmpl remote_write min_backoff 重复配置rel-24.01.23
| -rw-r--r-- | nz-admin/src/main/resources/db/R__AZ_sys_config.sql | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/nz-admin/src/main/resources/db/R__AZ_sys_config.sql b/nz-admin/src/main/resources/db/R__AZ_sys_config.sql index 7467c9a2..f603623c 100644 --- a/nz-admin/src/main/resources/db/R__AZ_sys_config.sql +++ b/nz-admin/src/main/resources/db/R__AZ_sys_config.sql @@ -90,5 +90,5 @@ REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (null, 'dc_export_header', '[{\"name\":\"Name\",\"i18n\":\"overall.name\",\"comment\":\"config.dc.name.comment\"},{\"name\":\"Location\",\"i18n\":\"asset.location\",\"comment\":\"config.dc.location.comment\"},{\"name\":\"Telephone\",\"i18n\":\"config.dc.tel\",\"comment\":\"config.dc.tel.comment\"},{\"name\":\"Principal\",\"i18n\":\"config.dc.principal\",\"comment\":\"config.dc.principal.comment\"},{\"name\":\"Longitude\",\"i18n\":\"config.dc.longitude\",\"comment\":\"config.dc.longitude.comment\"},{\"name\":\"Latitude\",\"i18n\":\"config.dc.latitude\",\"comment\":\"config.dc.latitude.comment\"},{\"name\":\"State\",\"i18n\":\"overall.state\",\"comment\":\"config.dc.state.comment\"},{\"name\":\"Remark\",\"i18n\":\"overall.dc.remark\",\"comment\":\"config.dc.remark.comment\"}]', 1, 'dc 导入导出表头信息'); REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'stat_query_json', '[{\n \"name\": \"asset\",\n \"datasql\": \"SELECT t.name as asset,t.*,atc.vm,atc.vmh,atc.NAME AS type,assc.NAME AS state,ab.NAME AS brand,am.NAME AS model,dc.NAME AS datacenter,cabinet.NAME AS cabinet,(CASE ap.`status` WHEN 1 THEN \'Up\' WHEN 0 THEN \'Down\' ELSE \'Suspended\' END) AS ping,(CASE WHEN amc.c IS NULL THEN 0 ELSE amc.c END) AS alert_message_count,(CASE WHEN mc.c IS NULL THEN 0 ELSE mc.c END) AS endpoint_count FROM asset_asset t LEFT JOIN asset_type_conf atc ON t.type_id=atc.id LEFT JOIN asset_state_conf assc ON t.state_id=assc.id LEFT JOIN asset_brand ab ON t.brand_id=ab.id LEFT JOIN asset_model am ON t.model_id=am.id LEFT JOIN dc ON t.dc_id=dc.id LEFT JOIN cabinet ON t.cabinet_id=cabinet.id LEFT JOIN (select * from asset_ping where type = \'mgt\') ap ON t.id=ap.asset_id LEFT JOIN (SELECT asset_id,count(1) AS c FROM alert_message_active ama WHERE ama.asset_id IS NOT NULL GROUP BY asset_id) amc ON amc.asset_id=t.id LEFT JOIN (SELECT asset_id,count(1) AS c FROM monitor_endpoint me GROUP BY asset_id) mc ON mc.asset_id=t.id\",\n \"group\": [{\n \"name\": \"ping\",\n \"expr\": \"ping\",\n \"type\": 2\n }, {\n \"name\": \"asset_type\",\n \"expr\": \"type\",\n \"type\": 2\n }, {\n \"name\": \"asset_state\",\n \"expr\": \"state\",\n \"type\": 2\n }, {\n \"name\": \"brand\",\n \"expr\": \"brand\",\n \"type\": 2\n }, {\n \"name\": \"model\",\n \"expr\": \"model\",\n \"type\": 2\n }, {\n \"name\": \"datacenter\",\n \"expr\": \"datacenter\",\n \"type\": 2\n }, {\n \"name\": \"cabinet\",\n \"expr\": \"cabinet\",\n \"type\": 2\n }, {\n \"name\": \"asset\",\n \"expr\": \"asset\",\n \"type\": 2\n }\n ],\n \"select\": [{\n \"name\": \"count\",\n \"expr\": \"count(1)\",\n \"type\": 1\n }, {\n \"name\": \"alert_message_sum\",\n \"expr\": \"sum(alert_message_count)\",\n \"type\": 1\n }, {\n \"name\": \"endpoint_sum\",\n \"expr\": \"sum(endpoint_count)\",\n \"type\": 1\n }\n ],\n \"filter\": [{\n \"name\": \"datacenter\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_datacenter_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"dc.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"dc.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"dc.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"dc.name not like \'%{{value}}%\'\"\n }\n ]\n }, {\n \"name\": \"asset\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_asset_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"t.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"t.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"t.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"t.name not like \'%{{value}}%\'\"\n }\n ]\n }, {\n \"name\": \"asset type\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_asset_type_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"atc.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"atc.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"atc.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"atc.name not like \'%{{value}}%\'\"\n }\n ]\n }, {\n \"name\": \"asset state\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_asset_state_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"assc.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"assc.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"assc.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"assc.name not like \'%{{value}}%\'\"\n }\n ]\n }, {\n \"name\": \"asset brand\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_asset_brand_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"ab.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"ab.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"ab.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"ab.name not like \'%{{value}}%\'\"\n }\n ]\n }, {\n \"name\": \"asset model\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_asset_model_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"am.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"am.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"am.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"am.name not like \'%{{value}}%\'\"\n }\n ]\n }, {\n \"name\": \"id\",\n \"type\": 1,\n \"rule\": [{\n \"regex\": \"\\\\d+\",\n \"tip\": \"filter_asset_id_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \">\",\n \"expr\": \"t.id > {{value}}\"\n }, {\n \"name\": \"=\",\n \"expr\": \"t.id = {{value}}\"\n }, {\n \"name\": \"<\",\n \"expr\": \"t.id < {{value}}\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"t.id != {{value}}\"\n }\n ]\n }\n ]\n }, {\n \"name\": \"datacenter\",\n \"datasql\": \"SELECT t.id,t.name as datacenter,(CASE WHEN cc.c IS NULL THEN 0 ELSE cc.c END) AS cabinet_count,(CASE WHEN ac.c IS NULL THEN 0 ELSE ac.c END) AS asset_count,(CASE WHEN amc.c IS NULL THEN 0 ELSE amc.c END) AS alert_message_count FROM dc t LEFT JOIN (SELECT dc_id,count(1) AS c FROM cabinet GROUP BY dc_id) cc ON cc.dc_id=t.id LEFT JOIN (SELECT dc_id,count(1) AS c FROM asset_asset GROUP BY dc_id) ac ON ac.dc_id=t.id LEFT JOIN (SELECT dc_id,count(1) AS c FROM alert_message_active ama WHERE ama.dc_id IS NOT NULL GROUP BY dc_id) amc ON amc.dc_id=t.id\",\n \"group\": [{\n \"name\": \"datacenter\",\n \"expr\": \"datacenter\",\n \"type\": 2\n }\n ],\n \"select\": [{\n \"name\": \"count\",\n \"expr\": \"count(1)\",\n \"type\": 1\n }, {\n \"name\": \"alert_message_sum\",\n \"expr\": \"sum(alert_message_count)\",\n \"type\": 1\n }, {\n \"name\": \"cabinet_sum\",\n \"expr\": \"sum(cabinet_count)\",\n \"type\": 1\n }, {\n \"name\": \"asset_sum\",\n \"expr\": \"sum(asset_count)\",\n \"type\": 1\n }\n ],\n \"filter\": [{\n \"name\": \"datacenter\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_datacenter_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"t.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"t.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"t.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"t.name not like \'%{{value}}%\'\"\n }\n ]\n }\n ]\n }, {\n \"name\": \"project\",\n \"datasql\": \"SELECT t.id,t.name as project,(CASE WHEN mm.c IS NULL THEN 0 ELSE mm.c END) AS module_count,(CASE WHEN aec.c IS NULL THEN 0 ELSE aec.c END) AS endpoint_count,(CASE WHEN aec.ac IS NULL THEN 0 ELSE aec.ac END) AS asset_count,(CASE WHEN amc.c IS NULL THEN 0 ELSE amc.c END) AS alert_message_count FROM monitor_project t LEFT JOIN (SELECT project_id,count(1) AS c FROM monitor_module GROUP BY project_id) mm ON mm.project_id=t.id LEFT JOIN (SELECT project_id,count(1) AS c FROM alert_message_active ama WHERE ama.project_id IS NOT NULL GROUP BY project_id) amc ON amc.project_id=t.id LEFT JOIN (SELECT project_id,count(1) AS c,count(DISTINCT e.asset_id) AS ac FROM monitor_endpoint e LEFT JOIN monitor_module m ON m.id=e.module_id GROUP BY m.project_id) aec ON aec.project_id=t.id\",\n \"group\": [{\n \"name\": \"project\",\n \"expr\": \"project\",\n \"type\": 2\n }\n ],\n \"select\": [{\n \"name\": \"count\",\n \"expr\": \"count(1)\",\n \"type\": 1\n }, {\n \"name\": \"alert_message_sum\",\n \"expr\": \"sum(alert_message_count)\",\n \"type\": 1\n }, {\n \"name\": \"module_sum\",\n \"expr\": \"sum(module_count)\",\n \"type\": 1\n }, {\n \"name\": \"endpoint_sum\",\n \"expr\": \"sum(endpoint_count)\",\n \"type\": 1\n }, {\n \"name\": \"asset_sum\",\n \"expr\": \"sum(asset_count)\",\n \"type\": 1\n }\n ],\n \"filter\": [{\n \"name\": \"project\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_project_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"t.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"t.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"t.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"t.name not like \'%{{value}}%\'\"\n }\n ]\n }\n ]\n }, {\n \"name\": \"module\",\n \"datasql\": \"SELECT t.id,t.NAME AS module,mp.NAME AS project,(CASE WHEN amc.c IS NULL THEN 0 ELSE amc.c END) AS alert_message_count,(CASE WHEN mc.c IS NULL THEN 0 ELSE mc.c END) AS endpoint_count,(CASE WHEN mc.ac IS NULL THEN 0 ELSE mc.ac END) AS asset_count FROM monitor_module t LEFT JOIN monitor_project mp ON t.project_id=mp.id LEFT JOIN (SELECT module_id,count(1) AS c FROM alert_message_active ama WHERE ama.module_id IS NOT NULL GROUP BY module_id) amc ON amc.module_id=t.id LEFT JOIN (SELECT module_id,count(1) AS c,count(DISTINCT asset_id) AS ac FROM monitor_endpoint me GROUP BY module_id) mc ON mc.module_id=t.id\",\n \"group\": [{\n \"name\": \"project\",\n \"expr\": \"project\",\n \"type\": 2\n }, {\n \"name\": \"module\",\n \"expr\": \"module\",\n \"type\": 2\n }\n ],\n \"select\": [{\n \"name\": \"count\",\n \"expr\": \"count(1)\",\n \"type\": 1\n }, {\n \"name\": \"alert_message_sum\",\n \"expr\": \"sum(alert_message_count)\",\n \"type\": 1\n }, {\n \"name\": \"endpoint_sum\",\n \"expr\": \"sum(endpoint_count)\",\n \"type\": 1\n }, {\n \"name\": \"asset_sum\",\n \"expr\": \"sum(asset_count)\",\n \"type\": 1\n }\n ],\n \"filter\": [{\n \"name\": \"project\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_project_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"mp.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"mp.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"mp.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"mp.name not like \'%{{value}}%\'\"\n }\n ]\n }, {\n \"name\": \"module\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_module_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"t.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"t.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"t.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"t.name not like \'%{{value}}%\'\"\n }\n ]\n }\n ]\n }, {\n \"name\": \"endpoint\",\n \"datasql\": \"SELECT \\tt.NAME AS endpoint, \\tt.*, \\tmm.NAME AS module, \\tmp.NAME AS project, \\tdc.NAME AS datacenter, \\taa.NAME AS asset, \\tatc.vm, \\tatc.vmh, \\tatc.NAME AS type, \\tassc.NAME AS state, \\tab.NAME AS brand, \\tam.NAME AS model, \\tcabinet.NAME AS cabinet, \\t( CASE WHEN amc.c IS NULL THEN 0 ELSE amc.c END ) AS alert_message_count FROM \\tmonitor_endpoint t \\tLEFT JOIN monitor_module mm ON t.module_id = mm.id \\tLEFT JOIN monitor_project mp ON mm.project_id = mp.id \\tLEFT JOIN asset_asset aa ON t.asset_id = aa.id \\tLEFT JOIN asset_type_conf atc ON aa.type_id = atc.id \\tLEFT JOIN asset_state_conf assc ON aa.state_id = assc.id \\tLEFT JOIN asset_brand ab ON aa.brand_id = ab.id \\tLEFT JOIN asset_model am ON aa.model_id = am.id \\tLEFT JOIN dc ON aa.dc_id = dc.id \\tLEFT JOIN cabinet ON aa.cabinet_id = cabinet.id \\tLEFT JOIN (select * from asset_ping where type = \'mgt\') ap ON aa.id = ap.asset_id \\tLEFT JOIN ( SELECT endpoint_id, count( 1 ) AS c FROM alert_message_active ama WHERE ama.endpoint_id IS NOT NULL GROUP BY endpoint_id ) amc ON amc.endpoint_id = t.id\",\n \"group\": [{\n \"name\": \"project\",\n \"expr\": \"project\",\n \"type\": 2\n }, {\n \"name\": \"module\",\n \"expr\": \"module\",\n \"type\": 2\n }, {\n \"name\": \"datacenter\",\n \"expr\": \"datacenter\",\n \"type\": 2\n }, {\n \"name\": \"asset\",\n \"expr\": \"asset\",\n \"type\": 2\n }, {\n \"name\": \"endpoint\",\n \"expr\": \"endpoint\",\n \"type\": 2\n }\n ],\n \"select\": [{\n \"name\": \"count\",\n \"expr\": \"count(1)\",\n \"type\": 1\n }, {\n \"name\": \"alert_message_sum\",\n \"expr\": \"sum(alert_message_count)\",\n \"type\": 1\n }\n ],\n \"filter\": [{\n \"name\": \"project\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_project_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"mp.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"mp.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"mp.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"mp.name not like \'%{{value}}%\'\"\n }\n ]\n }, {\n \"name\": \"module\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_module_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"mm.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"mm.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"mm.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"mm.name not like \'%{{value}}%\'\"\n }\n ]\n }, {\n \"name\": \"endpoint\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_endpoint_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"t.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"t.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"t.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"t.name not like \'%{{value}}%\'\"\n }\n ]\n }, {\n \"name\": \"datacenter\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_datacenter_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"dc.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"dc.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"dc.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"dc.name not like \'%{{value}}%\'\"\n }\n ]\n }, {\n \"name\": \"asset\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_asset_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"aa.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"aa.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"aa.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"aa.name not like \'%{{value}}%\'\"\n }\n ]\n }\n ]\n }, {\n \"name\": \"alert rule\",\n \"datasql\": \"SELECT t.id,t.NAME AS \'alertRule\',(CASE t.state WHEN 1 THEN \'Enabled\' WHEN 0 THEN \'Disabled\' ELSE \'Unkown\' END) AS state,(CASE t.type WHEN 1 THEN \'Metrics\' WHEN 2 THEN \'Logs\' WHEN 3 THEN \'SNMPTRAP\' ELSE \'Unkown\' END) AS typename,(CASE WHEN amc.c IS NULL THEN 0 ELSE amc.c END) AS alert_message_count FROM alert_rule t LEFT JOIN (SELECT rule_id,count(1) AS c FROM alert_message_active ama WHERE ama.rule_id IS NOT NULL GROUP BY rule_id) amc ON amc.rule_id=t.id\",\n \"group\": [{\n \"name\": \"type\",\n \"expr\": \"typename\",\n \"type\": 2\n }, {\n \"name\": \"state\",\n \"expr\": \"state\",\n \"type\": 2\n }, {\n \"name\": \"alert_rule\",\n \"expr\": \"alertRule\",\n \"type\": 2\n }\n ],\n \"select\": [{\n \"name\": \"count\",\n \"expr\": \"count(1)\",\n \"type\": 1\n }, {\n \"name\": \"alert_message_sum\",\n \"expr\": \"sum(alert_message_count)\",\n \"type\": 1\n }\n ],\n \"filter\": [{\n \"name\": \"alert rule\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_alert_rule_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"t.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"t.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"t.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"t.name not like \'%{{value}}%\'\"\n }\n ]\n }\n ]\n }, {\n \"name\": \"alert message\",\n \"datasql\": \"SELECT t.id,t.asset_id,t.endpoint_id,t.rule_id,t.project_id,t.module_id,t.dc_id,alsc.NAME AS severity,ar.NAME AS alert,(CASE ar.type WHEN 1 THEN \'Metrics\' WHEN 2 THEN \'Logs\' WHEN 3 THEN \'SNMPTRAP\' ELSE \'Unkown\' END) AS alertType,mp.NAME AS project,mm.NAME AS module,me.NAME AS endpoint,aa.NAME AS asset,dc.NAME AS datacenter FROM alert_message_active t LEFT JOIN alert_rule ar ON t.rule_id=ar.id LEFT JOIN monitor_project mp ON t.project_id=mp.id LEFT JOIN monitor_module mm ON t.module_id=mm.id LEFT JOIN monitor_endpoint me ON t.endpoint_id=me.id LEFT JOIN asset_asset aa ON t.asset_id=aa.id LEFT JOIN dc ON t.dc_id=dc.id LEFT JOIN alert_severity_conf alsc ON t.severity_id=alsc.id\",\n \"group\": [{\n \"name\": \"datacenter\",\n \"expr\": \"datacenter\",\n \"type\": 2\n }, {\n \"name\": \"project\",\n \"expr\": \"project\",\n \"type\": 2\n }, {\n \"name\": \"module\",\n \"expr\": \"module\",\n \"type\": 2\n }, {\n \"name\": \"endpoint\",\n \"expr\": \"endpoint\",\n \"type\": 2\n }, {\n \"name\": \"asset\",\n \"expr\": \"asset\",\n \"type\": 2\n }, {\n \"name\": \"alert_rule\",\n \"expr\": \"alert\",\n \"type\": 2\n }, {\n \"name\": \"priority\",\n \"expr\": \"severity\",\n \"type\": 2\n }\n ],\n \"select\": [{\n \"name\": \"count\",\n \"expr\": \"count(1)\",\n \"type\": 1\n }, {\n \"name\": \"affected_asset\",\n \"expr\": \"count(DISTINCT t.asset_id)\",\n \"type\": 1\n }, {\n \"name\": \"affected_datacenter\",\n \"expr\": \"count(DISTINCT t.dc_id)\",\n \"type\": 1\n }, {\n \"name\": \"affected_project\",\n \"expr\": \"count(DISTINCT t.project_id)\",\n \"type\": 1\n }, {\n \"name\": \"affected_module\",\n \"expr\": \"count(DISTINCT t.module_id)\",\n \"type\": 1\n }, {\n \"name\": \"affected_endpoint\",\n \"expr\": \"count(DISTINCT t.endpoint_id)\",\n \"type\": 1\n }, {\n \"name\": \"affected_alert_rule\",\n \"expr\": \"count(DISTINCT t.rule_id)\",\n \"type\": 1\n }\n ],\n \"filter\": [{\n \"name\": \"project\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_project_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"mp.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"mp.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"mp.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"mp.name not like \'%{{value}}%\'\"\n }\n ]\n }, {\n \"name\": \"module\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_module_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"mm.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"mm.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"mm.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"mm.name not like \'%{{value}}%\'\"\n }\n ]\n }, {\n \"name\": \"endpoint\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_endpoint_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"me.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"me.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"me.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"me.name not like \'%{{value}}%\'\"\n }\n ]\n }, {\n \"name\": \"datacenter\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_datacenter_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"dc.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"dc.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"dc.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"dc.name not like \'%{{value}}%\'\"\n }\n ]\n }, {\n \"name\": \"asset\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_asset_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"aa.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"aa.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"aa.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"aa.name not like \'%{{value}}%\'\"\n }\n ]\n }, {\n \"name\": \"priority\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_priority_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"alsc.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"alsc.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"alsc.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"alsc.name not like \'%{{value}}%\'\"\n }\n ]\n }, {\n \"name\": \"alert rule\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_alert_rule_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"ar.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"ar.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"ar.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"ar.name not like \'%{{value}}%\'\"\n }\n ]\n }\n ]\n }, {\n \"name\": \"agent\",\n \"datasql\": \"SELECT \\tt.id, \\tt.type, \\t( CASE t.STATUS WHEN 1 THEN \'Up\' ELSE \'Down\' END ) AS STATUS, \\t( CASE t.type WHEN 1 THEN \'Global\' WHEN 2 THEN \'Per-datacenter\' ELSE \'Unkown\' END ) AS typename, \\tdc.NAME AS datacenter FROM \\tagent t \\tLEFT JOIN dc ON t.dc_id = dc.id\",\n \"group\": [{\n \"name\": \"type\",\n \"expr\": \"type\",\n \"type\": 2\n }, {\n \"name\": \"state\",\n \"expr\": \"status\",\n \"type\": 2\n }, {\n \"name\": \"datacenter\",\n \"expr\": \"datacenter\",\n \"type\": 2\n }\n ],\n \"select\": [{\n \"name\": \"count\",\n \"expr\": \"count(1)\",\n \"type\": 1\n }\n ],\n \"filter\": [{\n \"name\": \"datacenter\",\n \"type\": 2,\n \"rule\": [{\n \"regex\": \".+\",\n \"tip\": \"filter_datacenter_is_null\"\n }\n ],\n \"opers\": [{\n \"name\": \"=\",\n \"expr\": \"dc.name = \'{{value}}\'\"\n }, {\n \"name\": \"~=\",\n \"expr\": \"dc.name like \'%{{value}}%\'\"\n }, {\n \"name\": \"!=\",\n \"expr\": \"dc.name != \'{{value}}\'\"\n }, {\n \"name\": \"!~\",\n \"expr\": \"dc.name not like \'%{{value}}%\'\"\n }\n ]\n }\n ]\n }\n]\n', 1, NULL); REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'prom_cmd_tmpl', '<#if currentAgent.type == 1>\r\nOPTION=\"--config.file=\'/opt/nezha/nz-agent/prometheus/prometheus.yml\' --web.listen-address=\'0.0.0.0:10091\' --storage.tsdb.retention.time=<#if systemConfig.metrics_storage_type?trim == \"1\">${systemConfig.metrics_storage_retention?trim}d<#else>${systemConfig.prometheus_default_retention_time_when_s3?trim}d</#if> --storage.tsdb.path=\'/data/prometheusData\' --web.enable-admin-api --enable-feature=\'remote-write-receiver\' --web.enable-lifecycle \"\r\n<#else>\r\nOPTION=\"--config.file=\'/opt/nezha/nz-agent/prometheus/prometheus.yml\' --web.listen-address=\'0.0.0.0:10091\' <#if systemConfig.prometheus_agent_mode?trim == \"1\">--enable-feature=remote-write-receiver,agent --storage.agent.retention.min-time=1h --storage.agent.retention.max-time=2h --storage.agent.wal-truncate-frequency=5m<#else> --enable-feature=\'remote-write-receiver\' --storage.tsdb.path=\'/data/prometheusData\' --storage.tsdb.retention.time=<#if systemConfig.metrics_storage_type?trim == \"1\">${systemConfig.metrics_storage_retention?trim}d<#else>${systemConfig.prometheus_default_retention_time_when_s3?trim}d</#if></#if> --web.enable-admin-api --web.enable-lifecycle \"\r\n</#if>', 1, 'prometheus 启动参数模板'); -REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'prom_yml_tmpl', '{\r\n \"global\": {\r\n \"scrape_interval\": \"${scrape_interval}s\",\r\n \"scrape_timeout\": <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n </#if>\r\n \"evaluation_interval\": \"${scrape_interval}s\"\r\n },\r\n \r\n <#-- alert 配置 -->\r\n <#if isAlert>\r\n \"alerting\": {\r\n \"alertmanagers\": [{\r\n \"path_prefix\": \"${path_prefix}\",\r\n \"static_configs\": [{\r\n \"targets\": [\"${alert_url}\"]\r\n }]\r\n }],\r\n \"alert_relabel_configs\": [{\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }, {\r\n \"regex\": \"replica\",\r\n \"action\": \"labeldrop\"\r\n }]\r\n },\r\n \"rule_files\": [\"rule.yml\"],\r\n </#if>\r\n \r\n \r\n \r\n <#-- per-datacenter 配置 -->\r\n <#if !isGlobal>\r\n \"scrape_configs\": [\r\n <#list jobList as jobPojo>\r\n {\r\n \"job_name\": \"${jobPojo.job_name}\",\r\n \"scheme\": \"${jobPojo.scheme?default(\"http\")}\",\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": <#if jobPojo.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${jobPojo.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n </#if>\r\n \"static_configs\":[\r\n <#list jobPojo.staticConfigList as staticConf >\r\n {\r\n \"targets\": [\r\n <#list staticConf.targets as targetConf>\r\n \"${targetConf}\"<#sep>,</#sep>\r\n </#list>\r\n ]\r\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\r\n ,\r\n \"labels\": {\r\n <#list staticConf.labels?keys as itemKey>\r\n \"${itemKey}\":<#if staticConf.labels[itemKey]?default(\"\")?trim?length gt 0>\r\n \"${staticConf.labels[itemKey]}\"\r\n <#else>\"\"</#if><#sep>,</#sep>\r\n </#list>\r\n } \r\n </#if>\r\n }<#sep>,</#sep>\r\n </#list>\r\n ],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n </#if>\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n </#if>\r\n ]\r\n }<#sep>,</#sep>\r\n </#list>\r\n <#if jobList??&&(jobList?size>0)>\r\n ,\r\n </#if>\r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n <#if endpoint.config.protocol == \"http\" || endpoint.config.protocol == \"https\">\r\n \"/metrics\",\r\n <#else>\r\n \"/snmp\",\r\n </#if>\r\n </#if>\r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval?c}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n </#if>\r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout?c}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n </#if>\r\n </#if>\r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n </#if>\r\n </#if>\r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n </#if>\r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.protocol == \"http\" || endpoint.config.protocol == \"https\" >\r\n \"scheme\": \"${endpoint.config.protocol}\",\r\n <#if endpoint.config.params?? && (endpoint.config.params?size >0) >\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,</#sep>\r\n </#list>\r\n ]\r\n <#sep>,</#sep>\r\n </#list>\r\n },\r\n </#if>\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n </#if>\r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\" || endpoint.config.protocol == \"https\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n </#if>\r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n </#if>\r\n\r\n \"nz_agent_id\": ${endpoint.agent.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n </#if>\r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,</#sep>\r\n </#if>\r\n </#list>\r\n </#if>\r\n }\r\n }],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if endpoint.config.relabel_config??&& (endpoint.config.relabel_config?size >0)>\r\n <#list endpoint.config.relabel_config as relabel>\r\n ,{\r\n <#if relabel.action?? && (relabel.action == \'labeldrop\' || relabel.action == \'labelkeep\')>\r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\"\r\n </#if>\r\n <#if relabel.action?? && relabel.action == \'labelmap\'>\r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\",\r\n \"replacement\": \"${(relabel.replacement)!\'\'}\"\r\n </#if>\r\n <#if relabel.action?? && (relabel.action == \'drop\' || relabel.action == \'keep\')>\r\n <#if relabel.source_labels??&& (relabel.source_labels?size >0)>\r\n \"source_labels\":[\r\n <#list relabel.source_labels as label>\r\n \"${label!\'\'}\"<#sep>,</#sep>\r\n </#list>\r\n ],\r\n </#if>\r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\"\r\n </#if>\r\n <#if relabel.action?? && relabel.action == \'replace\'>\r\n <#if relabel.source_labels??&& (relabel.source_labels?size >0)>\r\n \"source_labels\":[\r\n <#list relabel.source_labels as label>\r\n \"${label!\'\'}\"<#sep>,</#sep>\r\n </#list>\r\n ],\r\n </#if>\r\n \"separator\": \"${((relabel.separator!\'\')?length>0)?string((relabel.separator!\'\'),\";\")}\", \r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"replacement\": \"${(relabel.replacement)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\",\r\n \"target_label\": \"${(relabel.target_label)!\'\'}\"\r\n </#if>\r\n }\r\n </#list>\r\n </#if>\r\n ]\r\n }\r\n <#sep>,</#sep>\r\n </#list>\r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if endpointList??&&(endpointList?size>0)>\r\n ,\r\n </#if>\r\n \r\n <#-- ipmi_ip 配置 -->\r\n <#list blackboxIpmiJobList as asset>\r\n {\r\n \"job_name\": \"ipmi_ip_ping_${asset.id?c}\",\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n </#if>\r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n </#if>\r\n </#if>\r\n \"params\": {\r\n \"target\":[ \"${asset.ipmiIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"asset\": \"${asset.name}\",\r\n \"host\": \"${asset.ipmiIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.agent.host}\",\r\n \"nz_agent_id\": ${asset.agent.id?c},\r\n \"type\": \"ipmi\"\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,</#sep>\r\n </#list>\r\n \r\n <#if blackboxIpmiJobList??&&(blackboxIpmiJobList?size>0)>\r\n ,\r\n </#if>\r\n \r\n <#list blackboxMgtIpJobList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n </#if>\r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n </#if>\r\n </#if>\r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"asset\": \"${asset.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.agent.host}\",\r\n \"nz_agent_id\": ${asset.agent.id?c},\r\n \"type\": \"mgt\"\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,</#sep>\r\n </#list>\r\n ]\r\n <#-- cortex 处理 -->\r\n ,\r\n \"remote_write\": [\r\n <#list remoteWriteUrlInfos as remoteConf>\r\n {\r\n \"url\": \"${remoteConf.url}\",\r\n \"authorization\": {\r\n \"type\": \"Bearer\",\r\n \"credentials\": \"${remoteConf.token}\"\r\n },\r\n \"tls_config\":{\r\n \"insecure_skip_verify\":true\r\n },\r\n \"write_relabel_configs\": [\r\n {\r\n \"source_labels\": [\"nz_agent_id\"],\r\n \"regex\": \"${currentAgent.id?c}\",\r\n \"action\": \"keep\"\r\n }\r\n ],\r\n \"queue_config\":{\r\n \"capacity\": 5000,\r\n \"max_samples_per_send\": 1000,\r\n \"min_shards\": 5,\r\n \"max_shards\": 10,\r\n \"min_backoff\": \"20ms\",\r\n \"min_backoff\": \"50ms\",\r\n \"sample_age_limit\": \"2h\"\r\n }\r\n }\r\n <#sep>,</#sep>\r\n </#list>\r\n ]\r\n <#else>\r\n <#-- global 配置 -->\r\n \"scrape_configs\": [\r\n <#list jobList as jobPojo>\r\n {\r\n \"job_name\": \"${jobPojo.job_name}\",\r\n \"scheme\": \"${jobPojo.scheme?default(\"http\")}\",\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n <#if jobPojo.isFederate> \r\n \"honor_labels\": ${jobPojo.honor_labels},\r\n \"params\": {\r\n \"match[]\": [\r\n \"{__name__=~\\\".+\\\",nz_agent_id = \\\"${jobPojo.excludeAgentId?c}\\\"}\"\r\n ]\r\n },\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${jobPojo.token}\"\r\n },\r\n </#if>\r\n \"metrics_path\": <#if jobPojo.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${jobPojo.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n </#if>\r\n \"static_configs\":[\r\n <#list jobPojo.staticConfigList as staticConf >\r\n {\r\n \"targets\": [\r\n <#list staticConf.targets as targetConf>\r\n \"${targetConf}\"<#sep>,</#sep>\r\n </#list>\r\n ]\r\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\r\n ,\r\n \"labels\": {\r\n <#list staticConf.labels?keys as itemKey>\r\n \"${itemKey}\":<#if staticConf.labels[itemKey]?default(\"\")?trim?length gt 0>\r\n \"${staticConf.labels[itemKey]}\"\r\n <#else>\"\"</#if><#sep>,</#sep>\r\n </#list>\r\n } \r\n </#if>\r\n }<#sep>,</#sep>\r\n </#list>\r\n ],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n </#if>\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n </#if>\r\n ]\r\n }<#sep>,</#sep>\r\n </#list>\r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if jobList??&&(jobList?size>0)>\r\n ,\r\n </#if>\r\n \r\n <#-- ipmi_ip 配置 -->\r\n <#list blackboxIpmiJobList as asset>\r\n {\r\n \"job_name\": \"ipmi_ip_ping_${asset.id?c}\",\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n </#if>\r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n </#if>\r\n </#if>\r\n \"params\": {\r\n \"target\":[ \"${asset.ipmiIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"asset\": \"${asset.name}\",\r\n \"host\": \"${asset.ipmiIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.agent.host}\",\r\n \"nz_agent_id\": ${asset.agent.id?c},\r\n \"type\": \"ipmi\"\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,</#sep>\r\n </#list>\r\n \r\n <#if blackboxIpmiJobList??&&(blackboxIpmiJobList?size>0)>\r\n ,\r\n </#if>\r\n \r\n <#-- manage_ip 配置 -->\r\n <#list blackboxMgtIpJobList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n </#if>\r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n </#if>\r\n </#if>\r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"asset\": \"${asset.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.agent.host}\",\r\n \"nz_agent_id\": ${asset.agent.id?c},\r\n \"type\": \"mgt\"\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,</#sep>\r\n </#list>\r\n \r\n <#if blackboxMgtIpJobList??&&(blackboxMgtIpJobList?size>0)>\r\n ,\r\n </#if>\r\n \r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n <#if endpoint.config.protocol == \"http\" || endpoint.config.protocol == \"https\">\r\n \"/metrics\",\r\n <#else>\r\n \"/snmp\",\r\n </#if>\r\n </#if>\r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval?c}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n </#if>\r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout?c}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n </#if>\r\n </#if>\r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n </#if>\r\n </#if>\r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n </#if>\r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.protocol == \"http\" || endpoint.config.protocol == \"https\" >\r\n \"scheme\": \"${endpoint.config.protocol}\",\r\n <#if endpoint.config.params?? && (endpoint.config.params?size >0) >\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,</#sep>\r\n </#list>\r\n ]\r\n <#sep>,</#sep>\r\n </#list>\r\n },\r\n </#if>\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n </#if>\r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\" || endpoint.config.protocol == \"https\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n </#if>\r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n </#if>\r\n \r\n \"nz_agent_id\": ${endpoint.agent.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n </#if>\r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,</#sep>\r\n </#if>\r\n </#list>\r\n </#if>\r\n }\r\n }],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if endpoint.config.relabel_config??&& (endpoint.config.relabel_config?size >0)>\r\n <#list endpoint.config.relabel_config as relabel>\r\n ,{\r\n <#if relabel.action?? && (relabel.action == \'labeldrop\' || relabel.action == \'labelkeep\')>\r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\"\r\n </#if>\r\n <#if relabel.action?? && relabel.action == \'labelmap\'>\r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\",\r\n \"replacement\": \"${(relabel.replacement)!\'\'}\"\r\n </#if>\r\n <#if relabel.action?? && (relabel.action == \'drop\' || relabel.action == \'keep\')>\r\n <#if relabel.source_labels??&& (relabel.source_labels?size >0)>\r\n \"source_labels\":[\r\n <#list relabel.source_labels as label>\r\n \"${label!\'\'}\"<#sep>,</#sep>\r\n </#list>\r\n ],\r\n </#if>\r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\"\r\n </#if>\r\n <#if relabel.action?? && relabel.action == \'replace\'>\r\n <#if relabel.source_labels??&& (relabel.source_labels?size >0)>\r\n \"source_labels\":[\r\n <#list relabel.source_labels as label>\r\n \"${label!\'\'}\"<#sep>,</#sep>\r\n </#list>\r\n ],\r\n </#if>\r\n \"separator\": \"${((relabel.separator!\'\')?length>0)?string((relabel.separator!\'\'),\";\")}\", \r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"replacement\": \"${(relabel.replacement)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\",\r\n \"target_label\": \"${(relabel.target_label)!\'\'}\"\r\n </#if>\r\n }\r\n </#list>\r\n </#if>\r\n ]\r\n }\r\n <#sep>,</#sep>\r\n </#list>\r\n \r\n ]\r\n \r\n <#-- cortex 处理 -->\r\n ,\r\n \"remote_write\": [\r\n <#list remoteWriteUrlInfos as remoteConf>\r\n { \r\n \"url\": \"${remoteConf.url}\",\r\n \"authorization\": {\r\n \"type\": \"Bearer\",\r\n \"credentials\": \"${remoteConf.token}\"\r\n },\r\n \"tls_config\":{\r\n \"insecure_skip_verify\":true\r\n },\r\n \"write_relabel_configs\": [\r\n {\r\n \"source_labels\": [\"nz_agent_id\"],\r\n \"regex\": \"${currentAgent.id?c}\",\r\n \"action\": \"keep\"\r\n }\r\n ],\r\n \"queue_config\":{\r\n \"capacity\": 5000,\r\n \"max_samples_per_send\": 1000,\r\n \"min_shards\": 5,\r\n \"max_shards\": 10,\r\n \"min_backoff\": \"20ms\",\r\n \"min_backoff\": \"50ms\",\r\n \"sample_age_limit\": \"2h\"\r\n }\r\n }\r\n <#sep>,</#sep>\r\n </#list>\r\n ] \r\n </#if>\r\n \r\n <#-- tsdb 配置 -->\r\n ,\r\n \"storage\": {\r\n \"tsdb\": {\r\n \"out_of_order_time_window\": \"${systemConfig.prometheus_tsdb_out_of_order_time_window}h\"\r\n }\r\n }\r\n}', 1, 'prometheus config文件模板'); +REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'prom_yml_tmpl', '{\r\n \"global\": {\r\n \"scrape_interval\": \"${scrape_interval}s\",\r\n \"scrape_timeout\": <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n </#if>\r\n \"evaluation_interval\": \"${scrape_interval}s\"\r\n },\r\n \r\n <#-- alert 配置 -->\r\n <#if isAlert>\r\n \"alerting\": {\r\n \"alertmanagers\": [{\r\n \"path_prefix\": \"${path_prefix}\",\r\n \"static_configs\": [{\r\n \"targets\": [\"${alert_url}\"]\r\n }]\r\n }],\r\n \"alert_relabel_configs\": [{\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }, {\r\n \"regex\": \"replica\",\r\n \"action\": \"labeldrop\"\r\n }]\r\n },\r\n \"rule_files\": [\"rule.yml\"],\r\n </#if>\r\n \r\n \r\n \r\n <#-- per-datacenter 配置 -->\r\n <#if !isGlobal>\r\n \"scrape_configs\": [\r\n <#list jobList as jobPojo>\r\n {\r\n \"job_name\": \"${jobPojo.job_name}\",\r\n \"scheme\": \"${jobPojo.scheme?default(\"http\")}\",\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": <#if jobPojo.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${jobPojo.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n </#if>\r\n \"static_configs\":[\r\n <#list jobPojo.staticConfigList as staticConf >\r\n {\r\n \"targets\": [\r\n <#list staticConf.targets as targetConf>\r\n \"${targetConf}\"<#sep>,</#sep>\r\n </#list>\r\n ]\r\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\r\n ,\r\n \"labels\": {\r\n <#list staticConf.labels?keys as itemKey>\r\n \"${itemKey}\":<#if staticConf.labels[itemKey]?default(\"\")?trim?length gt 0>\r\n \"${staticConf.labels[itemKey]}\"\r\n <#else>\"\"</#if><#sep>,</#sep>\r\n </#list>\r\n } \r\n </#if>\r\n }<#sep>,</#sep>\r\n </#list>\r\n ],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n </#if>\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n </#if>\r\n ]\r\n }<#sep>,</#sep>\r\n </#list>\r\n <#if jobList??&&(jobList?size>0)>\r\n ,\r\n </#if>\r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n <#if endpoint.config.protocol == \"http\" || endpoint.config.protocol == \"https\">\r\n \"/metrics\",\r\n <#else>\r\n \"/snmp\",\r\n </#if>\r\n </#if>\r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval?c}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n </#if>\r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout?c}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n </#if>\r\n </#if>\r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n </#if>\r\n </#if>\r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n </#if>\r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.protocol == \"http\" || endpoint.config.protocol == \"https\" >\r\n \"scheme\": \"${endpoint.config.protocol}\",\r\n <#if endpoint.config.params?? && (endpoint.config.params?size >0) >\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,</#sep>\r\n </#list>\r\n ]\r\n <#sep>,</#sep>\r\n </#list>\r\n },\r\n </#if>\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n </#if>\r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\" || endpoint.config.protocol == \"https\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n </#if>\r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n </#if>\r\n\r\n \"nz_agent_id\": ${endpoint.agent.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n </#if>\r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,</#sep>\r\n </#if>\r\n </#list>\r\n </#if>\r\n }\r\n }],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if endpoint.config.relabel_config??&& (endpoint.config.relabel_config?size >0)>\r\n <#list endpoint.config.relabel_config as relabel>\r\n ,{\r\n <#if relabel.action?? && (relabel.action == \'labeldrop\' || relabel.action == \'labelkeep\')>\r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\"\r\n </#if>\r\n <#if relabel.action?? && relabel.action == \'labelmap\'>\r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\",\r\n \"replacement\": \"${(relabel.replacement)!\'\'}\"\r\n </#if>\r\n <#if relabel.action?? && (relabel.action == \'drop\' || relabel.action == \'keep\')>\r\n <#if relabel.source_labels??&& (relabel.source_labels?size >0)>\r\n \"source_labels\":[\r\n <#list relabel.source_labels as label>\r\n \"${label!\'\'}\"<#sep>,</#sep>\r\n </#list>\r\n ],\r\n </#if>\r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\"\r\n </#if>\r\n <#if relabel.action?? && relabel.action == \'replace\'>\r\n <#if relabel.source_labels??&& (relabel.source_labels?size >0)>\r\n \"source_labels\":[\r\n <#list relabel.source_labels as label>\r\n \"${label!\'\'}\"<#sep>,</#sep>\r\n </#list>\r\n ],\r\n </#if>\r\n \"separator\": \"${((relabel.separator!\'\')?length>0)?string((relabel.separator!\'\'),\";\")}\", \r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"replacement\": \"${(relabel.replacement)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\",\r\n \"target_label\": \"${(relabel.target_label)!\'\'}\"\r\n </#if>\r\n }\r\n </#list>\r\n </#if>\r\n ]\r\n }\r\n <#sep>,</#sep>\r\n </#list>\r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if endpointList??&&(endpointList?size>0)>\r\n ,\r\n </#if>\r\n \r\n <#-- ipmi_ip 配置 -->\r\n <#list blackboxIpmiJobList as asset>\r\n {\r\n \"job_name\": \"ipmi_ip_ping_${asset.id?c}\",\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n </#if>\r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n </#if>\r\n </#if>\r\n \"params\": {\r\n \"target\":[ \"${asset.ipmiIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"asset\": \"${asset.name}\",\r\n \"host\": \"${asset.ipmiIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.agent.host}\",\r\n \"nz_agent_id\": ${asset.agent.id?c},\r\n \"type\": \"ipmi\"\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,</#sep>\r\n </#list>\r\n \r\n <#if blackboxIpmiJobList??&&(blackboxIpmiJobList?size>0)>\r\n ,\r\n </#if>\r\n \r\n <#list blackboxMgtIpJobList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n </#if>\r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n </#if>\r\n </#if>\r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"asset\": \"${asset.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.agent.host}\",\r\n \"nz_agent_id\": ${asset.agent.id?c},\r\n \"type\": \"mgt\"\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,</#sep>\r\n </#list>\r\n ]\r\n <#-- cortex 处理 -->\r\n ,\r\n \"remote_write\": [\r\n <#list remoteWriteUrlInfos as remoteConf>\r\n {\r\n \"url\": \"${remoteConf.url}\",\r\n \"authorization\": {\r\n \"type\": \"Bearer\",\r\n \"credentials\": \"${remoteConf.token}\"\r\n },\r\n \"tls_config\":{\r\n \"insecure_skip_verify\":true\r\n },\r\n \"write_relabel_configs\": [\r\n {\r\n \"source_labels\": [\"nz_agent_id\"],\r\n \"regex\": \"${currentAgent.id?c}\",\r\n \"action\": \"keep\"\r\n }\r\n ],\r\n \"queue_config\":{\r\n \"capacity\": 5000,\r\n \"max_samples_per_send\": 1000,\r\n \"min_shards\": 5,\r\n \"max_shards\": 10,\r\n \"min_backoff\": \"20ms\",\r\n \"max_backoff\": \"50ms\",\r\n \"sample_age_limit\": \"2h\"\r\n }\r\n }\r\n <#sep>,</#sep>\r\n </#list>\r\n ]\r\n <#else>\r\n <#-- global 配置 -->\r\n \"scrape_configs\": [\r\n <#list jobList as jobPojo>\r\n {\r\n \"job_name\": \"${jobPojo.job_name}\",\r\n \"scheme\": \"${jobPojo.scheme?default(\"http\")}\",\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n <#if jobPojo.isFederate> \r\n \"honor_labels\": ${jobPojo.honor_labels},\r\n \"params\": {\r\n \"match[]\": [\r\n \"{__name__=~\\\".+\\\",nz_agent_id = \\\"${jobPojo.excludeAgentId?c}\\\"}\"\r\n ]\r\n },\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${jobPojo.token}\"\r\n },\r\n </#if>\r\n \"metrics_path\": <#if jobPojo.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${jobPojo.metrics_path}\",\r\n <#else>\r\n \"/metrics\",\r\n </#if>\r\n \"static_configs\":[\r\n <#list jobPojo.staticConfigList as staticConf >\r\n {\r\n \"targets\": [\r\n <#list staticConf.targets as targetConf>\r\n \"${targetConf}\"<#sep>,</#sep>\r\n </#list>\r\n ]\r\n <#if staticConf.labels ??&& (staticConf.labels?size >0)>\r\n ,\r\n \"labels\": {\r\n <#list staticConf.labels?keys as itemKey>\r\n \"${itemKey}\":<#if staticConf.labels[itemKey]?default(\"\")?trim?length gt 0>\r\n \"${staticConf.labels[itemKey]}\"\r\n <#else>\"\"</#if><#sep>,</#sep>\r\n </#list>\r\n } \r\n </#if>\r\n }<#sep>,</#sep>\r\n </#list>\r\n ],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n </#if>\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if !jobPojo.instanceRelabel> \r\n ,\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n </#if>\r\n ]\r\n }<#sep>,</#sep>\r\n </#list>\r\n \r\n <#-- ping 配置 -->\r\n \r\n <#if jobList??&&(jobList?size>0)>\r\n ,\r\n </#if>\r\n \r\n <#-- ipmi_ip 配置 -->\r\n <#list blackboxIpmiJobList as asset>\r\n {\r\n \"job_name\": \"ipmi_ip_ping_${asset.id?c}\",\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n </#if>\r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n </#if>\r\n </#if>\r\n \"params\": {\r\n \"target\":[ \"${asset.ipmiIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"asset\": \"${asset.name}\",\r\n \"host\": \"${asset.ipmiIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.agent.host}\",\r\n \"nz_agent_id\": ${asset.agent.id?c},\r\n \"type\": \"ipmi\"\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,</#sep>\r\n </#list>\r\n \r\n <#if blackboxIpmiJobList??&&(blackboxIpmiJobList?size>0)>\r\n ,\r\n </#if>\r\n \r\n <#-- manage_ip 配置 -->\r\n <#list blackboxMgtIpJobList as asset>\r\n {\r\n \"job_name\": \"asset_ping_${asset.id?c}\",\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": \"/probe\",\r\n \"scrape_interval\": <#if asset.assetPingInterval?default(\"\")?trim?length gt 0>\r\n \"${asset.assetPingInterval}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n </#if>\r\n \"scrape_timeout\": <#if asset.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${asset.scrape_timeout}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n </#if>\r\n </#if>\r\n \"params\": {\r\n \"target\":[ \"${asset.manageIp}\" ],\r\n \"module\":[ \"ping\" ]\r\n },\r\n \"static_configs\": [{\r\n \"targets\": [\"127.0.0.1:19115\"],\r\n \"labels\": {\r\n \"datacenter\": \"${asset.dc.name}\",\r\n \"asset\": \"${asset.name}\",\r\n \"host\": \"${asset.manageIp}\",\r\n \"module\": \"ping\",\r\n \"source_ip\": \"${asset.agent.host}\",\r\n \"nz_agent_id\": ${asset.agent.id?c},\r\n \"type\": \"mgt\"\r\n }\r\n }],\r\n \"relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n ]\r\n }\r\n <#sep>,</#sep>\r\n </#list>\r\n \r\n <#if blackboxMgtIpJobList??&&(blackboxMgtIpJobList?size>0)>\r\n ,\r\n </#if>\r\n \r\n <#list endpointList as endpoint>\r\n {\r\n \"job_name\": ${endpoint.id?c},\r\n \"tls_config\":{\r\n \"insecure_skip_verify\": true\r\n },\r\n \"metrics_path\": <#if endpoint.config.metrics_path?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.metrics_path}\",\r\n <#else>\r\n <#if endpoint.config.protocol == \"http\" || endpoint.config.protocol == \"https\">\r\n \"/metrics\",\r\n <#else>\r\n \"/snmp\",\r\n </#if>\r\n </#if>\r\n \"scrape_interval\": <#if endpoint.config.scrape_interval?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_interval?c}s\",\r\n <#else>\r\n \"${scrape_interval}s\",\r\n </#if>\r\n \"scrape_timeout\": <#if endpoint.config.scrape_timeout?default(\"\")?trim?length gt 0>\r\n \"${endpoint.config.scrape_timeout?c}s\",\r\n <#else>\r\n <#if scrape_timeout??> \r\n \"${scrape_timeout}s\",\r\n <#else>\r\n \"10s\",\r\n </#if>\r\n </#if>\r\n\r\n\r\n\r\n <#if endpoint.config.basic_auth??&& (endpoint.config.basic_auth?size >0)>\r\n <#if endpoint.config.basic_auth.username?default(\"\")?trim?length gt 0 && endpoint.config.basic_auth.password?default(\"\")?trim?length gt 0>\r\n \"basic_auth\":{\r\n \"username\": \"${endpoint.config.basic_auth.username}\",\r\n \"password\": \"${endpoint.config.basic_auth.password}\"\r\n },\r\n </#if>\r\n </#if>\r\n \r\n \r\n <#if endpoint.config.bearer_token??&&endpoint.config.bearer_token?trim?length gt 0>\r\n \"authorization\":{\r\n \"type\":\"Bearer\",\r\n \"credentials\":\"${endpoint.config.bearer_token}\"\r\n },\r\n </#if>\r\n\r\n \r\n <#-- params 不为空且类型为 http ,添加 params -->\r\n <#if endpoint.config.protocol == \"http\" || endpoint.config.protocol == \"https\" >\r\n \"scheme\": \"${endpoint.config.protocol}\",\r\n <#if endpoint.config.params?? && (endpoint.config.params?size >0) >\r\n \"params\":{\r\n <#list endpoint.config.params?keys as itemKey>\r\n \"${itemKey}\":[\r\n <#list endpoint.config.params[itemKey] as pojo>\r\n \"${pojo}\"\r\n <#sep>,</#sep>\r\n </#list>\r\n ]\r\n <#sep>,</#sep>\r\n </#list>\r\n },\r\n </#if>\r\n <#elseif endpoint.config.protocol == \"snmp\">\r\n <#-- 类型是 snmp ,组织 param 数据 , 原来params弃用,因为 snmp_exporter 不支持其他参数 -->\r\n \"params\":{\r\n \"target\":[ \"${endpoint.config.host}:${endpoint.config.port?c}\" ],\r\n \"module\":[ \"${endpoint.module.name}\" ]\r\n },\r\n </#if>\r\n \r\n \"static_configs\": [{\r\n \"targets\": [<#if endpoint.config.protocol == \"http\" || endpoint.config.protocol == \"https\">\r\n \"${endpoint.config.host}:${endpoint.config.port?c}\"\r\n <#else>\r\n \"127.0.0.1:19116\"\r\n </#if>\r\n ],\r\n \"labels\": {\r\n \"datacenter\": \"${endpoint.dc.name}\",\r\n \"datacenter_id\":${endpoint.dc.id?c},\r\n \r\n \"project\": \"${endpoint.project.name}\",\r\n \"project_id\": ${endpoint.project.id?c},\r\n \r\n \"asset\": \"${endpoint.asset.name}\",\r\n \"asset_id\": ${endpoint.asset.id?c},\r\n \r\n \"module\": \"${endpoint.module.name}\",\r\n \"module_id\": ${endpoint.module.id?c},\r\n \r\n \"endpoint\": \"${endpoint.name}\",\r\n \"endpoint_id\": ${endpoint.id?c},\r\n \r\n <#if endpoint.asset.parent??&&(endpoint.asset.parent?size >0)>\r\n \"parent_asset\" : \"${endpoint.asset.parent.name}\",\r\n \"parent_asset_id\" : ${endpoint.asset.parent.id?c},\r\n </#if>\r\n \r\n \"nz_agent_id\": ${endpoint.agent.id?c}\r\n \r\n \r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n ,\r\n </#if>\r\n <#-- 补充用户自定义 Labels -->\r\n <#if endpoint.config.labels??&& (endpoint.config.labels?size >0)>\r\n <#list endpoint.config.labels?keys as key>\r\n <#if key != \"datacenter\" && key != \"datacenter_id\" && key != \"project\" && key != \"project_id\" && key != \"asset\" && key != \"asset_id\" && key != \"module\" && key != \"module_id\" && key != \"endpoint\" && key != \"endpoint_id\">\r\n \"${key}\":\"${endpoint.config.labels[key]}\"<#sep>,</#sep>\r\n </#if>\r\n </#list>\r\n </#if>\r\n }\r\n }],\r\n \"metric_relabel_configs\": [\r\n {\r\n \"regex\": \"job\",\r\n \"action\": \"labeldrop\"\r\n },\r\n {\r\n \"regex\": \"instance\",\r\n \"action\": \"labeldrop\"\r\n }\r\n <#if endpoint.config.relabel_config??&& (endpoint.config.relabel_config?size >0)>\r\n <#list endpoint.config.relabel_config as relabel>\r\n ,{\r\n <#if relabel.action?? && (relabel.action == \'labeldrop\' || relabel.action == \'labelkeep\')>\r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\"\r\n </#if>\r\n <#if relabel.action?? && relabel.action == \'labelmap\'>\r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\",\r\n \"replacement\": \"${(relabel.replacement)!\'\'}\"\r\n </#if>\r\n <#if relabel.action?? && (relabel.action == \'drop\' || relabel.action == \'keep\')>\r\n <#if relabel.source_labels??&& (relabel.source_labels?size >0)>\r\n \"source_labels\":[\r\n <#list relabel.source_labels as label>\r\n \"${label!\'\'}\"<#sep>,</#sep>\r\n </#list>\r\n ],\r\n </#if>\r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\"\r\n </#if>\r\n <#if relabel.action?? && relabel.action == \'replace\'>\r\n <#if relabel.source_labels??&& (relabel.source_labels?size >0)>\r\n \"source_labels\":[\r\n <#list relabel.source_labels as label>\r\n \"${label!\'\'}\"<#sep>,</#sep>\r\n </#list>\r\n ],\r\n </#if>\r\n \"separator\": \"${((relabel.separator!\'\')?length>0)?string((relabel.separator!\'\'),\";\")}\", \r\n \"regex\": \"${(relabel.regex)!\'\'}\",\r\n \"replacement\": \"${(relabel.replacement)!\'\'}\",\r\n \"action\": \"${(relabel.action)!\'\'}\",\r\n \"target_label\": \"${(relabel.target_label)!\'\'}\"\r\n </#if>\r\n }\r\n </#list>\r\n </#if>\r\n ]\r\n }\r\n <#sep>,</#sep>\r\n </#list>\r\n \r\n ]\r\n \r\n <#-- cortex 处理 -->\r\n ,\r\n \"remote_write\": [\r\n <#list remoteWriteUrlInfos as remoteConf>\r\n { \r\n \"url\": \"${remoteConf.url}\",\r\n \"authorization\": {\r\n \"type\": \"Bearer\",\r\n \"credentials\": \"${remoteConf.token}\"\r\n },\r\n \"tls_config\":{\r\n \"insecure_skip_verify\":true\r\n },\r\n \"write_relabel_configs\": [\r\n {\r\n \"source_labels\": [\"nz_agent_id\"],\r\n \"regex\": \"${currentAgent.id?c}\",\r\n \"action\": \"keep\"\r\n }\r\n ],\r\n \"queue_config\":{\r\n \"capacity\": 5000,\r\n \"max_samples_per_send\": 1000,\r\n \"min_shards\": 5,\r\n \"max_shards\": 10,\r\n \"min_backoff\": \"20ms\",\r\n \"max_backoff\": \"50ms\",\r\n \"sample_age_limit\": \"2h\"\r\n }\r\n }\r\n <#sep>,</#sep>\r\n </#list>\r\n ] \r\n </#if>\r\n \r\n <#-- tsdb 配置 -->\r\n ,\r\n \"storage\": {\r\n \"tsdb\": {\r\n \"out_of_order_time_window\": \"${systemConfig.prometheus_tsdb_out_of_order_time_window}h\"\r\n }\r\n }\r\n}', 1, 'prometheus config文件模板'); REPLACE INTO `sys_config`(`id`, `param_key`, `param_value`, `status`, `remark`) VALUES (NULL, 'prometheus_tsdb_out_of_order_time_window', '3', 1, 'prometheus 允许摄取无序样本的最大时长,默认:2h,单位:h'); |
