TSG-21854 TFE使用fieldstat4序列化Manipulation Policy的metric并输出到kafka
This commit is contained in:
@@ -1404,7 +1404,12 @@ void proxy_send_metric_log(const struct tfe_stream * stream, struct proxy_http_c
|
||||
proxy_action_map[PX_ACTION_REJECT]="deny";
|
||||
proxy_action_map[PX_ACTION_WHITELIST]="allow";
|
||||
const char *manipulate_action_map[]= {"redirect","block","replace","hijack","insert","edit_element","run_script"};
|
||||
struct tfe_fieldstat_easy_t *fieldstat = tfe_get_fieldstat_handle();
|
||||
|
||||
struct filedstat_easy_manipulation *fieldstat = tfe_get_fieldstat_handle()->manipulation;
|
||||
if(fieldstat == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(i=0; i< ctx->n_enforce; i++)
|
||||
{
|
||||
@@ -1463,25 +1468,12 @@ void proxy_send_metric_log(const struct tfe_stream * stream, struct proxy_http_c
|
||||
in_bytes=0;
|
||||
out_bytes=0;
|
||||
}
|
||||
|
||||
tfe_fieldstat_easy_incrby(fieldstat, fieldstat->counter_array[COLUMN_HIT_COUNT], hit_cnt, fieldstat->tags[thread_id], TAG_MAX - 1, thread_id);
|
||||
tfe_fieldstat_easy_incrby(fieldstat, fieldstat->counter_array[COLUMN_IN_BYTES], in_bytes, fieldstat->tags[thread_id], TAG_MAX - 1, thread_id);
|
||||
tfe_fieldstat_easy_incrby(fieldstat, fieldstat->counter_array[COLUMN_OUT_BYTES], out_bytes, fieldstat->tags[thread_id], TAG_MAX - 1, thread_id);
|
||||
|
||||
tfe_fieldstat_manipulation_incrby(fieldstat, fieldstat->counter_array[COLUMN_HIT_COUNT], hit_cnt, fieldstat->tags[thread_id], TAG_MAX - 1, thread_id);
|
||||
tfe_fieldstat_manipulation_incrby(fieldstat, fieldstat->counter_array[COLUMN_IN_BYTES], in_bytes, fieldstat->tags[thread_id], TAG_MAX - 1, thread_id);
|
||||
tfe_fieldstat_manipulation_incrby(fieldstat, fieldstat->counter_array[COLUMN_OUT_BYTES], out_bytes, fieldstat->tags[thread_id], TAG_MAX - 1, thread_id);
|
||||
}
|
||||
|
||||
char **payload = NULL;
|
||||
size_t payload_len = 0;
|
||||
|
||||
fieldstat_easy_output_array(fieldstat->fseasy, &payload, &payload_len);
|
||||
if (payload)
|
||||
{
|
||||
for (size_t i = 0; i < payload_len; i++)
|
||||
{
|
||||
kafka_send(tfe_get_kafka_handle(), TOPIC_RULE_HITS, payload[i], strlen(payload[i]));
|
||||
FREE(&payload[i]);
|
||||
}
|
||||
FREE(&payload);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user