TFE 适配 fieldstat prometheus

This commit is contained in:
luwenpeng
2020-11-13 20:16:22 +06:00
parent 111f5fc4dc
commit 012f4f6602
3 changed files with 14 additions and 1 deletions

View File

@@ -114,6 +114,8 @@ void future_promise_library_init(const char* profile)
const char* app_name="FP"; const char* app_name="FP";
fs=FS_create_handle(); fs=FS_create_handle();
FS_set_para(fs, APP_NAME, app_name, strlen(app_name)+1); FS_set_para(fs, APP_NAME, app_name, strlen(app_name)+1);
value=1;
FS_set_para(fs, OUTPUT_PROMETHEUS, &value, sizeof(value));
value=0; value=0;
FS_set_para(fs, FLUSH_BY_DATE, &value, sizeof(value)); FS_set_para(fs, FLUSH_BY_DATE, &value, sizeof(value));
FS_set_para(fs, OUTPUT_DEVICE, stat_path, strlen(stat_path)+1); FS_set_para(fs, OUTPUT_DEVICE, stat_path, strlen(stat_path)+1);

View File

@@ -134,6 +134,8 @@ statsd_cycle=5
# 1:FS_OUTPUT_STATSD; 2:FS_OUTPUT_INFLUX_LINE # 1:FS_OUTPUT_STATSD; 2:FS_OUTPUT_INFLUX_LINE
statsd_format=2 statsd_format=2
histogram_bins=0.5,0.8,0.9,0.95 histogram_bins=0.5,0.8,0.9,0.95
statsd_set_prometheus_port=9001
statsd_set_prometheus_url_path=/tfe_prometheus
[traffic_mirror] [traffic_mirror]
enable=1 enable=1

View File

@@ -453,7 +453,8 @@ int tfe_stat_init(struct tfe_proxy * proxy, const char * profile)
fs_handle = FS_create_handle(); fs_handle = FS_create_handle();
FS_set_para(fs_handle, OUTPUT_DEVICE, fieldstat_output, (int)strlen(fieldstat_output) + 1); FS_set_para(fs_handle, OUTPUT_DEVICE, fieldstat_output, (int)strlen(fieldstat_output) + 1);
FS_set_para(fs_handle, APP_NAME, app_name, (int)strlen(app_name) + 1); FS_set_para(fs_handle, APP_NAME, app_name, (int)strlen(app_name) + 1);
value = 1;
FS_set_para(fs_handle, OUTPUT_PROMETHEUS, &value, sizeof(value));
value = 1; value = 1;
FS_set_para(fs_handle, PRINT_MODE, &value, sizeof(value)); FS_set_para(fs_handle, PRINT_MODE, &value, sizeof(value));
value = 0; value = 0;
@@ -555,6 +556,14 @@ int main(int argc, char * argv[])
breakpad_segv_generate(); breakpad_segv_generate();
} }
int prometheus_port = 9001;
char prometheus_url_path[1024] = {0};
MESA_load_profile_int_def(main_profile, "STAT", "statsd_set_prometheus_port", &(prometheus_port), 9001);
MESA_load_profile_string_def(main_profile, "STAT", "statsd_set_prometheus_url_path", prometheus_url_path, sizeof(prometheus_url_path), "/tfe_prometheus");
FS_library_set_prometheus_port(prometheus_port);
FS_library_set_prometheus_url_path(prometheus_url_path);
FS_library_init();
future_promise_library_init(future_profile); future_promise_library_init(future_profile);
tango_cache_global_init(); tango_cache_global_init();