TSG-21854 TFE使用fieldstat4序列化Manipulation Policy的metric并输出到kafka
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
#define MAAT_INPUT_FILE 2
|
||||
|
||||
static int scan_table_id[__SCAN_COMMON_TABLE_MAX];
|
||||
static struct tfe_fieldstat_easy_t *fieldstat_easy = NULL;
|
||||
static struct tfe_fieldstat_easy_t *fieldstat4_easy = NULL;
|
||||
static char *device_tag=NULL;
|
||||
|
||||
struct kafka *kafka_handle = NULL;
|
||||
@@ -65,30 +65,37 @@ struct maat *tfe_get_maat_handle()
|
||||
|
||||
struct tfe_fieldstat_easy_t *tfe_get_fieldstat_handle()
|
||||
{
|
||||
return fieldstat_easy;
|
||||
return fieldstat4_easy;
|
||||
}
|
||||
|
||||
static struct tfe_fieldstat_easy_t *create_fieldstat4_instance(const char *profile, const char *section, int max_thread, void *logger)
|
||||
static tfe_fieldstat_easy_t *create_fieldstat4_instance(const char *profile, const char *section, int max_thread, void *logger)
|
||||
{
|
||||
int cycle=0;
|
||||
char app_name[TFE_STRING_MAX]={0};
|
||||
char outpath[TFE_STRING_MAX]={0};
|
||||
struct tfe_fieldstat_easy_t *fieldstat_easy=NULL;
|
||||
int output_fs_interval_ms=0, output_kafka_interval_ms=0;
|
||||
struct tfe_fieldstat_easy_t *fieldstat_easy=NULL;
|
||||
|
||||
MESA_load_profile_string_def(profile, section, "app_name", app_name, sizeof(app_name), "proxy_rule_hits");
|
||||
MESA_load_profile_int_def(profile, section, "cycle", &cycle, 5);
|
||||
MESA_load_profile_string_def(profile, section, "outpath", outpath, sizeof(outpath), "metrics/porxy_fieldstat.json");
|
||||
MESA_load_profile_int_def(profile, section, "output_fs_interval_ms", &output_fs_interval_ms, 500);
|
||||
MESA_load_profile_int_def(profile, section, "output_kafka_interval_ms", &output_kafka_interval_ms, 1000);
|
||||
|
||||
fieldstat_easy = tfe_fieldstat_easy_create(app_name, outpath, cycle, max_thread, logger);
|
||||
fieldstat_easy = tfe_fieldstat_easy_create(output_kafka_interval_ms);
|
||||
if (fieldstat_easy == NULL)
|
||||
{
|
||||
TFE_LOG_ERROR(logger, "tfe fieldstat init failed, error to create fieldstat metric.");
|
||||
return NULL;
|
||||
}
|
||||
TFE_LOG_INFO(logger, "tfe fieldstat app_name : %s", app_name);
|
||||
TFE_LOG_INFO(logger, "tfe fieldstat cycle : %d", cycle);
|
||||
TFE_LOG_INFO(logger, "tfe fieldstat outpath : %s", outpath);
|
||||
|
||||
MESA_load_profile_string_def(profile, section, "app_name", app_name, sizeof(app_name), "proxy_rule_hits");
|
||||
MESA_load_profile_int_def(profile, section, "cycle", &cycle, 0);
|
||||
MESA_load_profile_string_def(profile, section, "outpath", outpath, sizeof(outpath), "metrics/porxy_fieldstat.json");
|
||||
fieldstat_easy->manipulation = tfe_fieldstat_easy_manipulation_create(app_name, outpath, cycle, max_thread, logger);
|
||||
|
||||
TFE_LOG_INFO(logger, "tfe fieldstat app_name : %s", app_name);
|
||||
TFE_LOG_INFO(logger, "tfe fieldstat cycle : %d", cycle);
|
||||
TFE_LOG_INFO(logger, "tfe fieldstat outpath : %s", outpath);
|
||||
TFE_LOG_INFO(logger, "tfe output_fs_interval_ms : %d", output_fs_interval_ms);
|
||||
TFE_LOG_INFO(logger, "tfe output_kafka_interval_ms : %d", output_kafka_interval_ms);
|
||||
return fieldstat_easy;
|
||||
}
|
||||
|
||||
@@ -377,8 +384,8 @@ int tfe_env_init()
|
||||
return -1;
|
||||
}
|
||||
|
||||
fieldstat_easy = create_fieldstat4_instance(profile_path, "proxy_hits", thread_num, g_default_logger);
|
||||
if(!fieldstat_easy)
|
||||
fieldstat4_easy = create_fieldstat4_instance(profile_path, "proxy_hits", thread_num, g_default_logger);
|
||||
if(!fieldstat4_easy)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user