TSG-14599 tsg-service-chaining-engine支持新的Metrics结构
This commit is contained in:
@@ -63,7 +63,7 @@ prometheus_listen_port=9001
|
|||||||
prometheus_listen_url=/sce_prometheus
|
prometheus_listen_url=/sce_prometheus
|
||||||
|
|
||||||
[metrics]
|
[metrics]
|
||||||
# Kafka Topic: SERVICE-CHAINING-METRICS
|
# Kafka Topic: POLICY-RULE-METRICS
|
||||||
enable=1
|
enable=1
|
||||||
interval_s=1
|
interval_s=1
|
||||||
telegraf_bind_address=127.0.0.1
|
telegraf_bind_address=127.0.0.1
|
||||||
|
|||||||
@@ -46,21 +46,17 @@
|
|||||||
drop_original = true
|
drop_original = true
|
||||||
stats = ["sum"]
|
stats = ["sum"]
|
||||||
fieldpass = ["sent_pkts", "sent_bytes", "recv_pkts", "recv_bytes"]
|
fieldpass = ["sent_pkts", "sent_bytes", "recv_pkts", "recv_bytes"]
|
||||||
namepass = ["service_chaining_metrics"] # only "pass" swap metrics through the aggregator.
|
namepass = ["service_chaining_rule_hits"] # only "pass" swap metrics through the aggregator.
|
||||||
|
|
||||||
[[outputs.file]]
|
[[outputs.file]]
|
||||||
files = ["/tmp/sce_metrics.json", "stdout"]
|
files = ["/tmp/sce_metrics.json", "stdout"]
|
||||||
data_format = "json"
|
data_format = "json"
|
||||||
json_transformation = '''
|
json_timestamp_units = "1ms"
|
||||||
$merge([{"timestamp": timestamp}, tags, fields])
|
|
||||||
'''
|
|
||||||
|
|
||||||
[[outputs.kafka]]
|
[[outputs.kafka]]
|
||||||
sasl_username = "admin"
|
sasl_username = "admin"
|
||||||
sasl_password = "galaxy2019"
|
sasl_password = "galaxy2019"
|
||||||
brokers = [ "192.168.44.12:9094" ]
|
brokers = [ "192.168.44.12:9094" ]
|
||||||
topic = "SERVICE-CHAINING-METRICS"
|
topic = "POLICY-RULE-METRICS"
|
||||||
data_format = "json"
|
data_format = "json"
|
||||||
json_transformation = '''
|
json_timestamp_units = "1ms"
|
||||||
$merge([{"timestamp": timestamp}, tags, fields])
|
|
||||||
'''
|
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "sf_metrics.h"
|
#include "sf_metrics.h"
|
||||||
|
|
||||||
#define SCE_SF_METRICS "SCE-SF-METRICS,rule_id=%lu,sff_profile_id=%d,sf_profile_id=%d,type=service_chaining_metrics sent_pkts=%lu,sent_bytes=%lu,recv_pkts=%lu,recv_bytes=%lu"
|
#define SCE_SF_METRICS "service_chaining_rule_hits,rule_id=%lu,sff_profile_id=%d,sf_profile_id=%d sent_pkts=%lu,sent_bytes=%lu,recv_pkts=%lu,recv_bytes=%lu"
|
||||||
|
|
||||||
struct key_tuple
|
struct key_tuple
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "sf_status.h"
|
#include "sf_status.h"
|
||||||
|
|
||||||
#define SCE_SF_STATUS "SCE-SF-STATUS,sf_profile_id=%d,type=service_function_status sf_status=%d,sf_latency_us=%d"
|
#define SCE_SF_STATUS "service_function_status,sf_profile_id=%d sf_status=%d,sf_latency_us=%d"
|
||||||
|
|
||||||
struct node
|
struct node
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,12 +7,32 @@ target_include_directories(gtest_policy PUBLIC ${CMAKE_SOURCE_DIR}/common/includ
|
|||||||
target_include_directories(gtest_policy PUBLIC ${CMAKE_SOURCE_DIR}/platform/include)
|
target_include_directories(gtest_policy PUBLIC ${CMAKE_SOURCE_DIR}/platform/include)
|
||||||
target_link_libraries(gtest_policy common platform gtest)
|
target_link_libraries(gtest_policy common platform gtest)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# gtest_sf_metrics
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
add_executable(gtest_sf_metrics gtest_sf_metrics.cpp)
|
||||||
|
target_include_directories(gtest_sf_metrics PUBLIC ${CMAKE_SOURCE_DIR}/common/include)
|
||||||
|
target_include_directories(gtest_sf_metrics PUBLIC ${CMAKE_SOURCE_DIR}/platform/include)
|
||||||
|
target_link_libraries(gtest_sf_metrics common platform gtest)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# gtest_sf_status
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
add_executable(gtest_sf_status gtest_sf_status.cpp)
|
||||||
|
target_include_directories(gtest_sf_status PUBLIC ${CMAKE_SOURCE_DIR}/common/include)
|
||||||
|
target_include_directories(gtest_sf_status PUBLIC ${CMAKE_SOURCE_DIR}/platform/include)
|
||||||
|
target_link_libraries(gtest_sf_status common platform gtest)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# gtest_discover_tests
|
# gtest_discover_tests
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
gtest_discover_tests(gtest_policy)
|
gtest_discover_tests(gtest_policy)
|
||||||
|
gtest_discover_tests(gtest_sf_metrics)
|
||||||
|
gtest_discover_tests(gtest_sf_status)
|
||||||
|
|
||||||
file(COPY ./test_resource/ DESTINATION ./test_resource/)
|
file(COPY ./test_resource/ DESTINATION ./test_resource/)
|
||||||
file(COPY ${CMAKE_SOURCE_DIR}/resource/table_info.conf DESTINATION ./test_resource/)
|
file(COPY ${CMAKE_SOURCE_DIR}/resource/table_info.conf DESTINATION ./test_resource/)
|
||||||
18
platform/test/gtest_sf_metrics.cpp
Normal file
18
platform/test/gtest_sf_metrics.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "sf_metrics.h"
|
||||||
|
|
||||||
|
TEST(SF_METRICS, TEST)
|
||||||
|
{
|
||||||
|
struct sf_metrics *metrics = sf_metrics_create("./test_resource/sce.conf");
|
||||||
|
EXPECT_TRUE(sf_metrics_get_interval(metrics) == 1);
|
||||||
|
sf_metrics_inc(metrics, 1, 2, 3, 4, 5, 6, 7);
|
||||||
|
sf_metrics_send(metrics);
|
||||||
|
sf_metrics_destory(metrics);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
|
}
|
||||||
19
platform/test/gtest_sf_status.cpp
Normal file
19
platform/test/gtest_sf_status.cpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "sf_status.h"
|
||||||
|
|
||||||
|
TEST(SF_STATUS, TEST)
|
||||||
|
{
|
||||||
|
struct sf_status *status = sf_status_create("./test_resource/sce.conf");
|
||||||
|
EXPECT_TRUE(sf_status_get_interval(status) == 1);
|
||||||
|
sf_status_update(status, 1, 0, 0);
|
||||||
|
sf_status_update(status, 2, 1, 1);
|
||||||
|
sf_status_send(status);
|
||||||
|
sf_status_destory(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
|
}
|
||||||
@@ -23,6 +23,13 @@ redis_db_idx=0
|
|||||||
redis_server=127.0.0.1
|
redis_server=127.0.0.1
|
||||||
redis_port_range=6379
|
redis_port_range=6379
|
||||||
|
|
||||||
|
[metrics]
|
||||||
|
# Kafka Topic: POLICY-RULE-METRICS
|
||||||
|
enable=1
|
||||||
|
interval_s=1
|
||||||
|
telegraf_bind_address=127.0.0.1
|
||||||
|
telegraf_listen_port=8300
|
||||||
|
|
||||||
[bfdd]
|
[bfdd]
|
||||||
path=/var/run/frr/bfdd.vty
|
path=/var/run/frr/bfdd.vty
|
||||||
device=eth0
|
device=eth0
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ prometheus_listen_port=9001
|
|||||||
prometheus_listen_url=/sce_prometheus
|
prometheus_listen_url=/sce_prometheus
|
||||||
|
|
||||||
[metrics]
|
[metrics]
|
||||||
# Kafka Topic: SERVICE-CHAINING-METRICS
|
# Kafka Topic: POLICY-RULE-METRICS
|
||||||
enable=0
|
enable=0
|
||||||
interval_s=1
|
interval_s=1
|
||||||
telegraf_bind_address=127.0.0.1
|
telegraf_bind_address=127.0.0.1
|
||||||
|
|||||||
Reference in New Issue
Block a user