2020#include " rapidjson/stringbuffer.h"
2121#include " rapidjson/writer.h"
2222
23+ #include " application/Application.h"
2324#include " collection_pipeline/queue/ProcessQueueItem.h"
2425#include " collection_pipeline/queue/ProcessQueueManager.h"
2526#include " common/HashUtil.h"
@@ -51,6 +52,7 @@ extern "C" {
5152DEFINE_FLAG_INT32 (ebpf_networkobserver_max_connections, " maximum connections" , 5000 );
5253DEFINE_FLAG_STRING (ebpf_networkobserver_enable_protocols, " enable application protocols, split by comma" , " HTTP" );
5354DEFINE_FLAG_DOUBLE (ebpf_networkobserver_default_sample_rate, " ebpf network observer default sample rate" , 1.0 );
55+ DEFINE_FLAG_STRING (ebpf_networkobserver_agent_env, " deploy env: ACSK8S,Serverless,ECS_AUTO" , " ACSK8S" );
5456
5557namespace logtail ::ebpf {
5658
@@ -1680,9 +1682,6 @@ const static std::string kAgentInfoServiceIdKey = "acs_arms_service_id";
16801682const static std::string kAgentInfoWorkspaceKey = " acs_cms_workspace" ;
16811683const static std::string kAgentInfoPropertiesKey = " properties" ;
16821684
1683- const static std::string kAgentInfoAgentEnvACKVal = " ACSK8S" ;
1684- const static std::string kAgentInfoAgentEnvECSAutoVal = " ECS_AUTO" ;
1685- const static std::string kAgentInfoAgentEnvDefaultVal = " DEFAULT" ;
16861685const static std::string kAgentInfoPropertiesKeyClusterId = " k8s.cluster.uid" ;
16871686const static std::string kAgentInfoPropertiesKeyClusterName = " k8s.cluster.name" ;
16881687const static std::string kAgentInfoPropertiesKeyNamespace = " k8s.namespace.name" ;
@@ -1740,18 +1739,26 @@ bool NetworkObserverManager::reportAgentInfo(const time_t& now,
17401739 event->SetContent (kAgentInfoAppIdKey , appConfig->mAppId );
17411740 event->SetContent (kAgentInfoAppnameKey , appConfig->mAppName );
17421741 event->SetContent (kAgentInfoAgentVersionKey , ILOGTAIL_VERSION);
1743- event->SetContentNoCopy (kAgentInfoAgentEnvKey , kAgentInfoAgentEnvACKVal );
1742+ event->SetContentNoCopy (kAgentInfoAgentEnvKey , STRING_FLAG (ebpf_networkobserver_agent_env));
1743+ event->SetContent (kAgentInfoAppIdKey , appConfig->mAppId );
1744+ event->SetContent (kAgentInfoServiceIdKey , appConfig->mServiceId );
1745+ event->SetContent (kAgentInfoWorkspaceKey , appConfig->mWorkspace );
17441746 if (Connection::gSelfPodIp .empty ()) {
17451747 event->SetContent (kAgentInfoIpKey , GetHostIp ());
17461748 } else {
17471749 event->SetContentNoCopy (kAgentInfoIpKey , Connection::gSelfPodIp );
17481750 }
1749-
17501751 if (Connection::gSelfPodName .empty ()) {
17511752 event->SetContent (kAgentInfoHostnameKey , GetHostName ());
17521753 } else {
17531754 event->SetContentNoCopy (kAgentInfoHostnameKey , Connection::gSelfPodName );
17541755 }
1756+ event->SetContent (kAgentInfoAppnameKey , appConfig->mAppName );
1757+ event->SetContent (kAgentInfoLanguageKey , appConfig->mLanguage );
1758+ event->SetContentNoCopy (kAgentInfoAgentVersionKey , ILOGTAIL_VERSION);
1759+ static auto sStartTime = ToString (Application::GetInstance ()->GetStartTime ()) + " 000" ;
1760+ event->SetContent (kAgentInfoStartTsKey , sStartTime ); // ms
1761+ event->SetContent (kAgentInfoTimestampKey , ToString (now * 1000 ));
17551762 event->SetTimestamp (now, 0 );
17561763 } else {
17571764 if (!K8sMetadata::GetInstance ().Enable ()) {
@@ -1769,6 +1776,7 @@ bool NetworkObserverManager::reportAgentInfo(const time_t& now,
17691776 LOG_DEBUG (sLogger , (" [AgentInfo] generate for cid" , containerId)(" podName" , podMeta->mPodName ));
17701777
17711778 auto * event = eventGroup.AddLogEvent (true , mEventPool );
1779+ event->SetContentNoCopy (kAgentInfoAgentEnvKey , STRING_FLAG (ebpf_networkobserver_agent_env));
17721780 event->SetContent (kAgentInfoAppIdKey , appConfig->mAppId );
17731781 event->SetContent (kAgentInfoServiceIdKey , appConfig->mServiceId );
17741782 event->SetContent (kAgentInfoWorkspaceKey , appConfig->mWorkspace );
0 commit comments