Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade environment variable logic using new Pipeline API for logtail environment configuration management #1282

Merged
merged 211 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
211 commits
Select commit Hold shift + click to select a range
756d817
complete pipeline definition (#1185)
henryzhx8 Oct 18, 2023
04b64ad
polish code
henryzhx8 Oct 18, 2023
5b301b9
Merge remote-tracking branch 'upstream/main' into feat/pipeline
henryzhx8 Oct 19, 2023
ef6b2a0
polish code
henryzhx8 Oct 19, 2023
5b76185
add pipeline implementation
henryzhx8 Oct 21, 2023
18ce59b
Merge remote-tracking branch 'upstream/main' into feat/pipeline
henryzhx8 Oct 21, 2023
b81b5bf
polish code
henryzhx8 Oct 21, 2023
b0fb7b0
seperate params from input_file
henryzhx8 Oct 22, 2023
255e512
polish code
henryzhx8 Oct 23, 2023
fbe3121
polish code
henryzhx8 Oct 23, 2023
a3ccba1
add file server
henryzhx8 Oct 23, 2023
f9af3e4
polish code
henryzhx8 Oct 24, 2023
fe77de3
polish code
henryzhx8 Oct 24, 2023
e2b622a
polish code
henryzhx8 Oct 24, 2023
957f820
Merge remote-tracking branch 'upstream/main' into feat/pipeline
henryzhx8 Oct 29, 2023
ae09dbb
fix bug
henryzhx8 Oct 29, 2023
adc9d3f
polish code
henryzhx8 Oct 29, 2023
e8b30b4
fix bug
henryzhx8 Oct 30, 2023
01c138d
polish code
henryzhx8 Oct 30, 2023
73f1dc4
refactor code
henryzhx8 Oct 30, 2023
5a0083f
refactor event dispatcher
henryzhx8 Oct 31, 2023
77eb3db
remove global filter
henryzhx8 Oct 31, 2023
39a35ae
refactor app config
henryzhx8 Oct 31, 2023
22be81f
remove shennong and streamlog
henryzhx8 Oct 31, 2023
25a3418
fix bug
henryzhx8 Oct 31, 2023
a16470d
upgrade V1 config to V2
henryzhx8 Oct 31, 2023
6cecdf1
fix bug
henryzhx8 Oct 31, 2023
a341cda
refactor pipeline management
henryzhx8 Nov 14, 2023
5819cfe
add ut
henryzhx8 Nov 15, 2023
696ddb1
add ut
henryzhx8 Nov 16, 2023
05fa6a3
fix e2e
henryzhx8 Nov 16, 2023
4921b06
polish code
henryzhx8 Nov 17, 2023
fc7784a
for tmp use
henryzhx8 Nov 18, 2023
1974bfd
for tmp use
henryzhx8 Nov 18, 2023
be7981a
polish code
henryzhx8 Nov 19, 2023
6bf179f
for tmp use
henryzhx8 Nov 19, 2023
ae7d4d6
for tmp use
henryzhx8 Nov 19, 2023
5e56fa0
fix
henryzhx8 Nov 19, 2023
565337f
fix e2e
henryzhx8 Nov 20, 2023
a7eebaf
temporarily remove observer case
henryzhx8 Nov 20, 2023
0270a36
fix e2e
henryzhx8 Nov 20, 2023
0b51b20
fix e2e
henryzhx8 Nov 20, 2023
2b7123f
polish code
henryzhx8 Nov 20, 2023
d4e558b
Yaml (#3)
quzard Nov 20, 2023
83e0a92
polish code
henryzhx8 Nov 20, 2023
fb24ba3
fix e2e
henryzhx8 Nov 21, 2023
e51de7e
remove old config
henryzhx8 Nov 21, 2023
46ef30c
cleanup gflags
henryzhx8 Nov 21, 2023
7ff3f01
merge main into branch
henryzhx8 Nov 21, 2023
82472c0
fix bug
henryzhx8 Nov 21, 2023
dc5ec41
merge main into branch
henryzhx8 Nov 21, 2023
a5c4cd8
merge pipeline into branch
henryzhx8 Nov 21, 2023
42fba17
polish code
henryzhx8 Nov 23, 2023
98bd681
polish code
henryzhx8 Nov 23, 2023
263a4d3
polish code
henryzhx8 Nov 23, 2023
f6a8588
fix bug
henryzhx8 Nov 24, 2023
b245b70
polish code
henryzhx8 Nov 24, 2023
3f8fba6
polish code
henryzhx8 Nov 24, 2023
f7ab5d9
fix code
henryzhx8 Nov 26, 2023
330d390
polish code
henryzhx8 Nov 26, 2023
1c457aa
polish
henryzhx8 Nov 26, 2023
bdf622a
fix code
henryzhx8 Nov 26, 2023
340db5c
fix
henryzhx8 Nov 26, 2023
04a2fa7
fix
henryzhx8 Nov 27, 2023
924a95c
polish code
henryzhx8 Nov 27, 2023
d00df4c
fix
henryzhx8 Nov 27, 2023
4843055
fix
henryzhx8 Nov 28, 2023
57694f7
fix
henryzhx8 Nov 28, 2023
10a62a3
polish
henryzhx8 Nov 28, 2023
a2a1f16
polish
henryzhx8 Nov 28, 2023
b6069cc
polish code
henryzhx8 Nov 28, 2023
6b41e7c
test
henryzhx8 Nov 28, 2023
790db9c
merge upstream/main into branch
henryzhx8 Nov 28, 2023
cca9087
merge upstream/pipeline into branch
henryzhx8 Nov 28, 2023
22f76fd
test
henryzhx8 Nov 28, 2023
9f4cc0b
polish
henryzhx8 Nov 29, 2023
0e6d6fd
fix observer
henryzhx8 Nov 29, 2023
0564f97
polish test
henryzhx8 Nov 29, 2023
d1413e6
fix code
henryzhx8 Nov 29, 2023
3a5d24f
polish code
henryzhx8 Nov 29, 2023
53a27ba
polish code
henryzhx8 Nov 29, 2023
7781d0a
fix bug
henryzhx8 Nov 30, 2023
566a118
Pipeline processor (#2)
quzard Nov 30, 2023
2fdaa44
polish code
henryzhx8 Dec 3, 2023
23c41d6
polish
henryzhx8 Dec 3, 2023
1e685f7
polish
henryzhx8 Dec 3, 2023
6da4fb3
polish code
henryzhx8 Dec 4, 2023
3426d6d
Merge pull request #1238 from henryzhx8/stage4
henryzhx8 Dec 4, 2023
c3d0a9a
polish code
henryzhx8 Dec 4, 2023
500a83b
In order to achieve a relatively unified interface for SPL and other …
linrunqi08 Dec 5, 2023
3e8b2b1
polish code
henryzhx8 Dec 5, 2023
689c977
Merge remote-tracking branch 'upstream/feat/pipeline' into feat/pipeline
henryzhx8 Dec 5, 2023
f3fbeb2
polish
henryzhx8 Dec 5, 2023
5763b6a
polish
henryzhx8 Dec 5, 2023
71ae546
polish code
henryzhx8 Dec 5, 2023
61c31fd
polish
henryzhx8 Dec 5, 2023
0ecc49c
fix code
henryzhx8 Dec 6, 2023
75d3d24
fix
henryzhx8 Dec 6, 2023
2875046
fix
henryzhx8 Dec 7, 2023
229f4df
polish code
henryzhx8 Dec 7, 2023
ff02fdd
新的sdk
quzard Dec 7, 2023
8215df6
add log
henryzhx8 Dec 7, 2023
03451e0
fix
henryzhx8 Dec 7, 2023
7ae34b3
fix bug
henryzhx8 Dec 7, 2023
2b91382
fix
quzard Dec 7, 2023
209d6c6
fix
henryzhx8 Dec 8, 2023
759d499
fix bug
henryzhx8 Dec 8, 2023
28d87ed
polish
henryzhx8 Dec 8, 2023
b801628
fix
quzard Dec 8, 2023
ba72059
fix
quzard Dec 8, 2023
448925e
fix
quzard Dec 8, 2023
736b1b1
fix
quzard Dec 8, 2023
a2a6935
merge remote branch into feat/pipeline
henryzhx8 Dec 8, 2023
3e50f45
fix
henryzhx8 Dec 8, 2023
fd4ac3b
Merge remote-tracking branch 'github_alibaba/feat/pipeline' into merg…
SteveYitao Dec 8, 2023
46d4cee
Merge remote-tracking branch 'github_alibaba/main' into mergeMain
SteveYitao Dec 8, 2023
814b3eb
fix
henryzhx8 Dec 8, 2023
328f04b
Merge processor changes of main branches (#1259)
quzard Dec 8, 2023
801405e
Merge remote-tracking branch 'github_alibaba/feat/pipeline' into merg…
SteveYitao Dec 8, 2023
aa436b9
Merge pull request #1261 from quzard/mergeMain
henryzhx8 Dec 8, 2023
9c9286c
polish
henryzhx8 Dec 9, 2023
33fe1d0
Merge remote-tracking branch 'upstream/feat/pipeline' into feat/pipeline
henryzhx8 Dec 9, 2023
e5c8af9
add alarm
Dec 11, 2023
456f718
polish
Dec 11, 2023
2e5733e
polish
Dec 11, 2023
9f02230
polish
Dec 11, 2023
94ff42a
Merge remote-tracking branch 'upstream/main' into feat/pipeline
Dec 11, 2023
2a01ca6
polish code
Dec 11, 2023
49a3f07
polish
Dec 11, 2023
5f2f9a3
Merge remote-tracking branch 'alibaba/feat/pipeline' into env
quzard Dec 13, 2023
3745067
fix
quzard Dec 13, 2023
cd54aed
nginxIngressProcessor
quzard Dec 14, 2023
655691a
fix
quzard Dec 14, 2023
3001398
fix
quzard Dec 14, 2023
5725890
fix
quzard Dec 14, 2023
fb29ad8
fix
quzard Dec 14, 2023
9c6f193
fix
quzard Dec 14, 2023
e9ed0d0
fix
quzard Dec 14, 2023
404317e
fix
quzard Dec 15, 2023
098424a
fix
quzard Dec 15, 2023
9a6e2f9
fix
quzard Dec 15, 2023
b5a657e
fix
quzard Dec 15, 2023
65c5631
fix
quzard Dec 15, 2023
4d73a2c
fix
quzard Dec 15, 2023
c969dd7
fix
quzard Dec 15, 2023
7c525dc
fix
quzard Dec 15, 2023
ea2e128
fix
quzard Dec 15, 2023
02e851f
fix
quzard Dec 15, 2023
82a4a00
fix
quzard Dec 15, 2023
40f0b74
Merge branch 'fix/k8s_event-nil-panic' into env
quzard Dec 15, 2023
3862194
Merge remote-tracking branch 'origin/env' into env
quzard Dec 15, 2023
d95b176
fix
quzard Dec 15, 2023
d287673
fix
quzard Dec 15, 2023
3f077fc
Add eventRecorder to the operationWrapper
quzard Dec 18, 2023
d29e38b
fix envTagsLock
quzard Dec 18, 2023
59c6fe7
fix
quzard Dec 18, 2023
e00f658
RLock
quzard Dec 18, 2023
0b380cc
fix
quzard Dec 18, 2023
0e781b9
Merge branch 'fix/k8s_event-nil-panic' into env
quzard Dec 18, 2023
a0e87e6
modify Lock
quzard Dec 18, 2023
81c66b5
/**/逻辑修改
quzard Dec 19, 2023
855ff93
rm
quzard Dec 19, 2023
13e6282
fix
quzard Dec 19, 2023
64c4b0a
fix
quzard Dec 19, 2023
1b611d9
fix CustomErrorFromSlsSDKError
quzard Dec 19, 2023
1c5d2f1
fix
quzard Dec 19, 2023
2121627
Merge remote-tracking branch 'upstream/main' into feat/pipeline
Dec 23, 2023
55af02c
Merge remote-tracking branch 'alibaba/feat/pipeline' into env
quzard Dec 23, 2023
d85cce8
fix
quzard Dec 23, 2023
4a3747a
polish code
Dec 23, 2023
809c021
fix
quzard Dec 23, 2023
0998621
polish
Dec 23, 2023
8065d8d
fix
quzard Dec 23, 2023
9ec6d51
fix
quzard Dec 23, 2023
5579638
add TestCheckFileConfigChanged
quzard Dec 23, 2023
49931ca
fix
quzard Dec 23, 2023
aabfeeb
fix
quzard Dec 23, 2023
851055e
add TestSplitLogPathAndFilePattern
quzard Dec 23, 2023
44ff73f
fix
quzard Dec 23, 2023
2ec5aa7
Info
quzard Dec 23, 2023
dae0050
只当发生更新了,才打印config updated日志
quzard Dec 24, 2023
c147967
打印needUpdate
quzard Dec 24, 2023
e47036a
不打印aliyunECSRamURL
quzard Dec 24, 2023
915d227
只打印role
quzard Dec 24, 2023
adc302d
使用读写锁优化一下
quzard Dec 24, 2023
4531690
fix
quzard Dec 24, 2023
0bd5704
fix log
quzard Dec 24, 2023
236af9a
fix log
quzard Dec 24, 2023
3431f5b
忽略github.com/alibabacloud-go
quzard Dec 24, 2023
5df1488
fix
quzard Dec 24, 2023
0a32af5
fix license
quzard Dec 24, 2023
8348cef
Merge remote-tracking branch 'alibaba/feat/pipeline' into env
quzard Dec 24, 2023
9c8ff76
add changelog
quzard Dec 24, 2023
387f897
make lint
quzard Dec 24, 2023
ee72c5e
fix
quzard Dec 25, 2023
acf1ba6
maxDirSearchDepth = 10
quzard Dec 25, 2023
ba859a6
Merge remote-tracking branch 'alibaba/main' into env
quzard Dec 25, 2023
c1e06cb
fix k8s-nginx-ingress
quzard Dec 25, 2023
422e0c1
fix /**/
quzard Dec 25, 2023
0319b03
fix
quzard Dec 25, 2023
dce09a6
fix log
quzard Dec 25, 2023
dae1ece
fix
quzard Dec 25, 2023
306e159
skip update
quzard Dec 25, 2023
dce9166
fix
quzard Dec 25, 2023
7eb4ec7
fix
quzard Dec 25, 2023
714c1cb
fix
quzard Dec 25, 2023
a15fda2
fix
quzard Dec 25, 2023
cf849de
**client
quzard Dec 26, 2023
c248c46
fix
quzard Dec 26, 2023
d57f9d3
add AliyunLogClient
quzard Dec 26, 2023
1e012c2
log
quzard Dec 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ your changes, such as:
## [Unreleased]

- [public] [both] [added] add UsingOldContentTag. When UsingOldContentTag is set to false, the Tag is now placed in the Meta instead of Logs during cgo.
- [public] [both] [added] Env control using the new configuration
39 changes: 30 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/VictoriaMetrics/VictoriaMetrics v1.83.1
github.com/alibaba/ilogtail/pkg v0.0.0
github.com/aliyun/alibaba-cloud-sdk-go/services/sls_inner v0.0.0
github.com/aliyun/aliyun-log-go-sdk v0.1.37
github.com/apache/pulsar-client-go v0.10.0
github.com/buger/jsonparser v1.1.1
github.com/cespare/xxhash v1.1.0 // indirect
Expand Down Expand Up @@ -56,7 +55,7 @@ require (
go.opentelemetry.io/collector/pdata v0.66.0
go.opentelemetry.io/proto/otlp v0.19.0
go.uber.org/atomic v1.10.0
golang.org/x/sys v0.6.0
golang.org/x/sys v0.9.0
google.golang.org/grpc v1.53.0
google.golang.org/protobuf v1.31.0
gotest.tools v2.2.0+incompatible
Expand Down Expand Up @@ -152,7 +151,6 @@ require (
github.com/Microsoft/hcsshim v0.9.4 // indirect
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1483
github.com/andrewkroh/sys v0.0.0-20151128191922-287798fe3e43 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/containerd/cgroups v1.0.4 // indirect
github.com/containerd/containerd v1.6.8 // indirect
github.com/containerd/continuity v0.2.2 // indirect
Expand Down Expand Up @@ -190,7 +188,7 @@ require (
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
Expand Down Expand Up @@ -237,12 +235,12 @@ require (
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.9.0
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/crypto v0.10.0 // indirect
golang.org/x/net v0.11.0 // indirect
golang.org/x/oauth2 v0.5.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/term v0.9.0 // indirect
golang.org/x/text v0.10.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
Expand Down Expand Up @@ -284,7 +282,30 @@ require (
sigs.k8s.io/gateway-api v0.6.2 // indirect
)

require github.com/rogpeppe/go-internal v1.6.1 // indirect
require (
github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.5
github.com/alibabacloud-go/sls-20201230/v5 v5.1.2
github.com/alibabacloud-go/tea v1.2.1
)

require (
github.com/alibabacloud-go/alibabacloud-gateway-sls v0.0.6 // indirect
github.com/alibabacloud-go/alibabacloud-gateway-sls-util v0.0.1 // indirect
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.4 // indirect
github.com/alibabacloud-go/darabonba-array v0.1.0 // indirect
github.com/alibabacloud-go/darabonba-encode-util v0.0.2 // indirect
github.com/alibabacloud-go/darabonba-map v0.0.2 // indirect
github.com/alibabacloud-go/darabonba-signature-util v0.0.7 // indirect
github.com/alibabacloud-go/darabonba-string v1.0.2 // indirect
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect
github.com/alibabacloud-go/openapi-util v0.1.0 // indirect
github.com/alibabacloud-go/tea-utils v1.3.1 // indirect
github.com/alibabacloud-go/tea-utils/v2 v2.0.4 // indirect
github.com/alibabacloud-go/tea-xml v1.1.3 // indirect
github.com/aliyun/credentials-go v1.3.1 // indirect
github.com/clbanning/mxj/v2 v2.5.5 // indirect
github.com/tjfoc/gmsm v1.4.1 // indirect
)

replace (
github.com/VictoriaMetrics/VictoriaMetrics => github.com/iLogtail/VictoriaMetrics v1.83.4-ilogtail
Expand Down
107 changes: 85 additions & 22 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion helper/envconfig/aliyun_ecs_meta_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func getToken() (result []byte, err error) {
role := roles[0]

var respGet *http.Response
logger.Debug(context.Background(), "get token request", aliyunECSRamURL+role)
logger.Info(context.Background(), "get token request", aliyunECSRamURL+role)
respGet, err = client.Get(aliyunECSRamURL + role)
if err != nil {
logger.Warning(context.Background(), "UPDATE_STS_ALARM", "get token error", err, "role", role)
Expand Down
149 changes: 72 additions & 77 deletions helper/envconfig/aliyun_log_config_define.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import (
"strings"
"time"

aliyunlog "github.com/aliyun/aliyun-log-go-sdk"
"github.com/alibabacloud-go/tea/tea"

aliyunlog "github.com/alibabacloud-go/sls-20201230/v5/client"
"github.com/gogo/protobuf/proto"

"github.com/alibaba/ilogtail/pkg/flags"
Expand Down Expand Up @@ -93,29 +95,29 @@ import (

// AliyunLogConfigSpec logtail config struct for wrapper
type AliyunLogConfigSpec struct {
Project string `json:"project"`
Logstore string `json:"logstore"`
ShardCount *int32 `json:"shardCount"`
LifeCycle *int32 `json:"lifeCycle"`
MachineGroups []string `json:"machineGroups"`
LogtailConfig AliyunLogConfigDetail `json:"logtailConfig"`
ContainerName string `json:"containerName"`
HashCode []byte `json:"hashCode"`
ErrorCount int `json:"errorCount"`
NextTryTime int64 `json:"nextTryTime"`
SimpleConfig bool `json:"simpleConfig"`
LastFetchTime int64 `json:"lastFetchTime"`
ProductCode string `json:"productCode"`
ProductLang string `json:"productLang"`
LogstoreMode string `json:"logstoreMode"`
LogstoreHotTTL *int32 `json:"logstoreHotTTL"`
LogstoreTelemetryType string `json:"logstoreTelemetryType"`
LogstoreAppendMeta bool `json:"logstoreAppendMeta"`
LogstoreMaxSplitShard *int32 `json:"logstoreMaxSplitShard"`
LogstoreEnableTracking bool `json:"logstoreEnableTracking"`
LogstoreAutoSplit bool `json:"logstoreAutoSplit"`
LogstoreEncryptConf aliyunlog.EncryptConf `json:"logstoreEncryptConf"`
ConfigTags map[string]string `json:"configTags"`
Project string `json:"project"`
Logstore string `json:"logstore"`
ShardCount *int32 `json:"shardCount"`
LifeCycle *int32 `json:"lifeCycle"`
MachineGroups []string `json:"machineGroups"`
LogtailConfig aliyunlog.LogtailPipelineConfig `json:"logtailConfig"`
ContainerName string `json:"containerName"`
HashCode []byte `json:"hashCode"`
ErrorCount int `json:"errorCount"`
NextTryTime int64 `json:"nextTryTime"`
SimpleConfig bool `json:"simpleConfig"`
LastFetchTime int64 `json:"lastFetchTime"`
ProductCode string `json:"productCode"`
ProductLang string `json:"productLang"`
LogstoreMode string `json:"logstoreMode"`
LogstoreHotTTL *int32 `json:"logstoreHotTTL"`
LogstoreTelemetryType string `json:"logstoreTelemetryType"`
LogstoreAppendMeta bool `json:"logstoreAppendMeta"`
LogstoreMaxSplitShard *int32 `json:"logstoreMaxSplitShard"`
LogstoreEnableTracking bool `json:"logstoreEnableTracking"`
LogstoreAutoSplit bool `json:"logstoreAutoSplit"`
LogstoreEncryptConf aliyunlog.EncryptConf `json:"logstoreEncryptConf"`
ConfigTags map[string]string `json:"configTags"`
}

const (
Expand All @@ -131,13 +133,6 @@ const (
SlsMachinegroupDeployModeDeamonset string = "deamonset"
)

// AliyunLogConfigDetail logtail config detail
type AliyunLogConfigDetail struct {
ConfigName string `json:"configName"`
InputType string `json:"inputType"`
LogtailConfig map[string]interface{} `json:"inputDetail"`
}

// Hash generate sha256 hash
func (alcs *AliyunLogConfigSpec) hash(hashValue string) {
h := sha256.New()
Expand All @@ -147,16 +142,7 @@ func (alcs *AliyunLogConfigSpec) hash(hashValue string) {

// Key return the unique key
func (alcs *AliyunLogConfigSpec) Key() string {
return alcs.Project + "@" + alcs.LogtailConfig.ConfigName + "@" + alcs.ContainerName
}

// InitFromDockerInfo init AliyunLogConfigDetail from docker info with specific config name
func (alcs *AliyunLogConfigDetail) InitFromDockerInfo(dockerInfo *helper.DockerInfoDetail,
config string,
configKeys []string,
configValues []string) error {

return nil
return alcs.Project + "@" + tea.StringValue(alcs.LogtailConfig.ConfigName) + "@" + alcs.ContainerName
}

// all log config spec, must been cleared before next process
Expand All @@ -183,8 +169,9 @@ func isDockerStdout(configType string) bool {

// nolint: unparam
func initDockerStdoutConfig(dockerInfo *helper.DockerInfoDetail, config *AliyunLogConfigSpec, configType string) {
config.LogtailConfig.InputType = "plugin"
config.LogtailConfig.Inputs = make([]map[string]interface{}, 0, 1)
stdoutDetail := make(map[string]interface{})
stdoutDetail["Type"] = "service_docker_stdout"
switch configType {
case "stdout":
stdoutDetail["Stdout"] = true
Expand All @@ -204,54 +191,62 @@ func initDockerStdoutConfig(dockerInfo *helper.DockerInfoDetail, config *AliyunL
// }
// }
stdoutDetail["IncludeEnv"] = map[string]string{
*flags.LogConfigPrefix + config.LogtailConfig.ConfigName: configType,
}
stdoutConfig := map[string]interface{}{
"type": "service_docker_stdout",
"detail": stdoutDetail,
}
config.LogtailConfig.LogtailConfig = map[string]interface{}{
"plugin": map[string]interface{}{
"inputs": []interface{}{stdoutConfig},
"global": map[string]interface{}{
"AlwaysOnline": true,
},
},
*flags.LogConfigPrefix + tea.StringValue(config.LogtailConfig.ConfigName): configType,
}
config.LogtailConfig.Inputs = append(config.LogtailConfig.Inputs, stdoutDetail)
config.LogtailConfig.Global = map[string]interface{}{"AlwaysOnline": true}
}

const invalidFilePattern = "invalid_file_pattern"

// nolint: unparam
func initFileConfig(k8sInfo *helper.K8SInfo, config *AliyunLogConfigSpec, filePath string, jsonFlag, dockerFile bool) {
config.LogtailConfig.InputType = "file"
config.LogtailConfig.Inputs = make([]map[string]interface{}, 0, 1)

// 判断有没有 /**/
maxDirSearchDepth := 0
if strings.Contains(filePath, "/**/") {
maxDirSearchDepth = 10
}

logPath, filePattern, err := splitLogPathAndFilePattern(filePath)
var input map[string]interface{}
if err != nil {
logger.Error(context.Background(), "INVALID_DOCKER_ENV_CONFIG_ALARM", "invalid file config, you must input full file path", filePath, err)
}

if !jsonFlag {
config.LogtailConfig.LogtailConfig = map[string]interface{}{
"logType": "common_reg_log",
"logPath": logPath,
"filePattern": filePattern,
"dockerFile": dockerFile,
"dockerIncludeEnv": map[string]string{
*flags.LogConfigPrefix + config.LogtailConfig.ConfigName: filePath,
input = map[string]interface{}{
"Type": "input_file",
"FilePaths": []string{logPath + filePattern},
"EnableContainerDiscovery": dockerFile,
"ContainerFilters": map[string]map[string]interface{}{
"IncludeEnv": {
*flags.LogConfigPrefix + tea.StringValue(config.LogtailConfig.ConfigName): filePath,
},
},
"MaxDirSearchDepth": maxDirSearchDepth,
}
} else {
config.LogtailConfig.LogtailConfig = map[string]interface{}{
"logType": "json_log",
"logPath": logPath,
"filePattern": filePattern,
"dockerFile": dockerFile,
"dockerIncludeEnv": map[string]string{
*flags.LogConfigPrefix + config.LogtailConfig.ConfigName: filePath,
input = map[string]interface{}{
"Type": "input_file",
"FilePaths": []string{logPath + filePattern},
"EnableContainerDiscovery": dockerFile,
"ContainerFilters": map[string]map[string]interface{}{
"IncludeEnv": {
*flags.LogConfigPrefix + tea.StringValue(config.LogtailConfig.ConfigName): filePath,
},
},
"MaxDirSearchDepth": maxDirSearchDepth,
}
config.LogtailConfig.Processors = []map[string]interface{}{
{
"SourceKey": "content",
"Type": "processor_parse_json_native",
},
}
}

config.LogtailConfig.Inputs = append(config.LogtailConfig.Inputs, input)
// remove container name limit, this will not work when pod with a sidecar/init container which has same env
// if len(k8sInfo.Namespace) > 0 {
// config.LogtailConfig.LogtailConfig["dockerIncludeLabel"] = map[string]string{
Expand All @@ -261,6 +256,7 @@ func initFileConfig(k8sInfo *helper.K8SInfo, config *AliyunLogConfigSpec, filePa
}

func isJSONFile(envConfigInfo *helper.EnvConfigInfo, config *AliyunLogConfigSpec) bool {
// aliyun_logs_****_jsonfile=true or aliyun_logs_****_jsonfile=TRUE
if jsonfile, ok := envConfigInfo.ConfigItemMap["jsonfile"]; ok && (jsonfile == "true" || jsonfile == "TRUE") {
return true
}
Expand All @@ -285,7 +281,7 @@ func makeLogConfigSpec(dockerInfo *helper.DockerInfoDetail, envConfigInfo *helpe
config.LastFetchTime = time.Now().Unix()
// save all config info, and keep sequence
var totalConfig string
config.LogtailConfig.ConfigName = envConfigInfo.ConfigName
config.LogtailConfig.ConfigName = tea.String(envConfigInfo.ConfigName)
// @note add image name to prevent key conflict
if len(dockerInfo.K8SInfo.ContainerName) > 0 {
config.ContainerName = dockerInfo.K8SInfo.ContainerName
Expand Down Expand Up @@ -414,13 +410,12 @@ func makeLogConfigSpec(dockerInfo *helper.DockerInfoDetail, envConfigInfo *helpe
// config
// makesure exist
configType := envConfigInfo.ConfigItemMap[""]
config.LogtailConfig.LogtailConfig = make(map[string]interface{})

if configDetail, ok := envConfigInfo.ConfigItemMap["detail"]; ok {
totalConfig += configDetail
if err := json.Unmarshal([]byte(configDetail), &config.LogtailConfig.LogtailConfig); err != nil {
logger.Error(context.Background(), "INVALID_ENV_CONFIG_DETAIL", "unmarshal error", err, "detail", configDetail)
}
config.LogtailConfig.InputType = configType
// if err := json.Unmarshal([]byte(configDetail), &config.LogtailConfig); err != nil {
// logger.Error(context.Background(), "INVALID_ENV_CONFIG_DETAIL", "unmarshal error", err, "detail", configDetail)
// }
config.SimpleConfig = false
} else {
totalConfig += configType
Expand Down
2 changes: 1 addition & 1 deletion helper/envconfig/aliyun_log_config_define_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strings"
)

const invalidLogPath = "/invalid_log_path"
const invalidLogPath = "/invalid_log_path/"

func splitLogPathAndFilePattern(filePath string) (logPath string, filePattern string, err error) {
lastSeperatorPos := strings.LastIndexByte(filePath, '/')
Expand Down
Loading
Loading