Skip to content

Commit 5bd3b2d

Browse files
committed
fix: resolved confilct
Signed-off-by: yuluo-yx <yuluo08290126@gmail.com>
2 parents c74b538 + 100f8f0 commit 5bd3b2d

File tree

13 files changed

+1338
-7
lines changed

13 files changed

+1338
-7
lines changed

go.mod

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ require (
1111
github.com/go-sql-driver/mysql v1.9.3
1212
github.com/lib/pq v1.10.9
1313
github.com/microsoft/go-mssqldb v1.9.3
14+
github.com/milvus-io/milvus-sdk-go/v2 v2.4.2
1415
github.com/prometheus/client_golang v1.23.0
1516
github.com/prometheus/common v0.65.0
1617
github.com/redis/go-redis/v9 v9.17.1
@@ -28,23 +29,37 @@ require (
2829
filippo.io/edwards25519 v1.1.0 // indirect
2930
github.com/beorn7/perks v1.0.1 // indirect
3031
github.com/cespare/xxhash/v2 v2.3.0 // indirect
32+
github.com/cockroachdb/errors v1.9.1 // indirect
33+
github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f // indirect
34+
github.com/cockroachdb/redact v1.1.3 // indirect
3135
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
3236
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
37+
github.com/getsentry/sentry-go v0.12.0 // indirect
3338
github.com/goccy/go-json v0.10.0 // indirect
39+
github.com/gogo/protobuf v1.3.2 // indirect
3440
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
3541
github.com/golang-sql/sqlexp v0.1.0 // indirect
42+
github.com/golang/protobuf v1.5.4 // indirect
3643
github.com/google/flatbuffers v23.1.21+incompatible // indirect
3744
github.com/google/uuid v1.6.0 // indirect
45+
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
3846
github.com/inconshreveable/mousetrap v1.1.0 // indirect
3947
github.com/klauspost/compress v1.18.0 // indirect
4048
github.com/klauspost/cpuid/v2 v2.2.3 // indirect
49+
github.com/kr/pretty v0.3.1 // indirect
50+
github.com/kr/text v0.2.0 // indirect
51+
github.com/milvus-io/milvus-proto/go-api/v2 v2.4.10-0.20240819025435-512e3b98866a // indirect
4152
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
4253
github.com/pierrec/lz4/v4 v4.1.17 // indirect
54+
github.com/pkg/errors v0.9.1 // indirect
4355
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
4456
github.com/prometheus/client_model v0.6.2 // indirect
4557
github.com/prometheus/procfs v0.16.1 // indirect
4658
github.com/rogpeppe/go-internal v1.13.1 // indirect
4759
github.com/spf13/pflag v1.0.9 // indirect
60+
github.com/tidwall/gjson v1.14.4 // indirect
61+
github.com/tidwall/match v1.1.1 // indirect
62+
github.com/tidwall/pretty v1.2.0 // indirect
4863
github.com/yuin/gopher-lua v1.1.1 // indirect
4964
github.com/zeebo/xxh3 v1.0.2 // indirect
5065
go.uber.org/multierr v1.11.0 // indirect

go.sum

Lines changed: 358 additions & 0 deletions
Large diffs are not rendered by default.

internal/cmd/version/version.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
* under the License.
1818
*/
1919

20-
// Copyright Envoy Gateway Authors
21-
// SPDX-License-Identifier: Apache-2.0
22-
// The full text of the Apache license is available in the LICENSE file at
23-
// the root of the repo.
24-
2520
package version
2621

2722
import (

internal/collector/basic/redis/redis_collector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
"github.com/redis/go-redis/v9"
3232
"golang.org/x/crypto/ssh"
3333

34-
sshhelper "hertzbeat.apache.org/hertzbeat-collector-go/internal/collector/common/ssh"
34+
sshhelper "hertzbeat.apache.org/hertzbeat-collector-go/internal/util/ssh"
3535
jobtypes "hertzbeat.apache.org/hertzbeat-collector-go/internal/collector/common/types/job"
3636
"hertzbeat.apache.org/hertzbeat-collector-go/internal/collector/common/types/job/protocol"
3737
consts "hertzbeat.apache.org/hertzbeat-collector-go/internal/constants"

internal/collector/basic/ssh/ssh_collector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import (
2626
"strings"
2727
"time"
2828

29-
sshhelper "hertzbeat.apache.org/hertzbeat-collector-go/internal/collector/common/ssh"
3029
jobtypes "hertzbeat.apache.org/hertzbeat-collector-go/internal/collector/common/types/job"
3130
"hertzbeat.apache.org/hertzbeat-collector-go/internal/collector/common/types/job/protocol"
3231
consts "hertzbeat.apache.org/hertzbeat-collector-go/internal/constants"
3332
"hertzbeat.apache.org/hertzbeat-collector-go/internal/util/logger"
3433
"hertzbeat.apache.org/hertzbeat-collector-go/internal/util/param"
34+
sshhelper "hertzbeat.apache.org/hertzbeat-collector-go/internal/util/ssh"
3535
)
3636

3737
const (

internal/collector/common/collect/dispatch/metrics_collector.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
_ "hertzbeat.apache.org/hertzbeat-collector-go/internal/collector/basic"
3535
"hertzbeat.apache.org/hertzbeat-collector-go/internal/collector/common/collect/strategy"
3636
jobtypes "hertzbeat.apache.org/hertzbeat-collector-go/internal/collector/common/types/job"
37+
_ "hertzbeat.apache.org/hertzbeat-collector-go/internal/collector/extension/milvus"
3738
"hertzbeat.apache.org/hertzbeat-collector-go/internal/constants"
3839
"hertzbeat.apache.org/hertzbeat-collector-go/internal/util/logger"
3940
"hertzbeat.apache.org/hertzbeat-collector-go/internal/util/param"

internal/collector/common/types/job/metrics_types.go

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ type Metrics struct {
5353
JMX *protocol.JMXProtocol `json:"jmx,omitempty"`
5454
Redis *protocol.RedisProtocol `json:"redis,omitempty"`
5555
MongoDB *protocol.MongoDBProtocol `json:"mongodb,omitempty"`
56+
Milvus *protocol.MilvusProtocol `json:"milvus,omitempty"`
5657
}
5758

5859
// Field represents a metric field
@@ -169,6 +170,119 @@ type ValueRow struct {
169170

170171
// Protocol specific types
171172

173+
// HTTPProtocol represents HTTP protocol configuration
174+
type HTTPProtocol struct {
175+
URL string `json:"url"`
176+
Method string `json:"method"`
177+
Headers map[string]string `json:"headers"`
178+
Params map[string]string `json:"params"`
179+
Body string `json:"body"`
180+
ParseScript string `json:"parseScript"`
181+
ParseType string `json:"parseType"`
182+
Keyword string `json:"keyword"`
183+
Timeout string `json:"timeout"`
184+
SSL string `json:"ssl"`
185+
Authorization *Authorization `json:"authorization"`
186+
}
187+
188+
// Authorization represents HTTP authorization configuration
189+
type Authorization struct {
190+
Type string `json:"type"`
191+
BasicAuthUsername string `json:"basicAuthUsername"`
192+
BasicAuthPassword string `json:"basicAuthPassword"`
193+
DigestAuthUsername string `json:"digestAuthUsername"`
194+
DigestAuthPassword string `json:"digestAuthPassword"`
195+
BearerTokenToken string `json:"bearerTokenToken"`
196+
}
197+
198+
// SSHProtocol represents SSH protocol configuration
199+
type SSHProtocol struct {
200+
Host string `json:"host"`
201+
Port string `json:"port"`
202+
Username string `json:"username"`
203+
Password string `json:"password"`
204+
PrivateKey string `json:"privateKey"`
205+
PrivateKeyPassphrase string `json:"privateKeyPassphrase"`
206+
Script string `json:"script"`
207+
ParseType string `json:"parseType"`
208+
ParseScript string `json:"parseScript"`
209+
Timeout string `json:"timeout"`
210+
ReuseConnection string `json:"reuseConnection"`
211+
UseProxy string `json:"useProxy"`
212+
ProxyHost string `json:"proxyHost"`
213+
ProxyPort string `json:"proxyPort"`
214+
ProxyUsername string `json:"proxyUsername"`
215+
ProxyPassword string `json:"proxyPassword"`
216+
ProxyPrivateKey string `json:"proxyPrivateKey"`
217+
}
218+
219+
// JDBCProtocol represents JDBC protocol configuration
220+
type JDBCProtocol struct {
221+
Host string `json:"host"`
222+
Port string `json:"port"`
223+
Platform string `json:"platform"`
224+
Username string `json:"username"`
225+
Password string `json:"password"`
226+
Database string `json:"database"`
227+
Timeout string `json:"timeout"`
228+
QueryType string `json:"queryType"`
229+
SQL string `json:"sql"`
230+
URL string `json:"url"`
231+
ReuseConnection string `json:"reuseConnection"`
232+
SSHTunnel *protocol.SSHTunnel `json:"sshTunnel,omitempty"`
233+
}
234+
235+
// SNMPProtocol represents SNMP protocol configuration
236+
type SNMPProtocol struct {
237+
Host string `json:"host"`
238+
Port int `json:"port"`
239+
Version string `json:"version"`
240+
Community string `json:"community"`
241+
Username string `json:"username"`
242+
AuthType string `json:"authType"`
243+
AuthPasswd string `json:"authPasswd"`
244+
PrivType string `json:"privType"`
245+
PrivPasswd string `json:"privPasswd"`
246+
ContextName string `json:"contextName"`
247+
Timeout int `json:"timeout"`
248+
Operation string `json:"operation"`
249+
OIDs string `json:"oids"`
250+
}
251+
252+
// JMXProtocol represents JMX protocol configuration
253+
type JMXProtocol struct {
254+
Host string `json:"host"`
255+
Port int `json:"port"`
256+
Username string `json:"username"`
257+
Password string `json:"password"`
258+
Protocol string `json:"protocol"`
259+
URL string `json:"url"`
260+
Timeout int `json:"timeout"`
261+
}
262+
263+
// RedisProtocol represents Redis protocol configuration
264+
type RedisProtocol struct {
265+
Host string `json:"host"`
266+
Port string `json:"port"`
267+
Username string `json:"username"`
268+
Password string `json:"password"`
269+
Pattern string `json:"pattern"`
270+
Timeout string `json:"timeout"`
271+
SSHTunnel *protocol.SSHTunnel `json:"sshTunnel,omitempty"`
272+
}
273+
274+
// MongoDBProtocol represents MongoDB protocol configuration
275+
type MongoDBProtocol struct {
276+
Host string `json:"host"`
277+
Port int `json:"port"`
278+
Username string `json:"username"`
279+
Password string `json:"password"`
280+
Database string `json:"database"`
281+
AuthDatabase string `json:"authDatabase"`
282+
Command string `json:"command"`
283+
Timeout int `json:"timeout"`
284+
}
285+
172286
// GetInterval returns the interval for the metric, using default if not set
173287
func (m *Metrics) GetInterval() time.Duration {
174288
if m.Interval > 0 {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package protocol
2+
3+
import (
4+
"hertzbeat.apache.org/hertzbeat-collector-go/internal/util/logger"
5+
)
6+
7+
// MilvusProtocol represents Milvus protocol configuration
8+
type MilvusProtocol struct {
9+
Host string `json:"host"`
10+
Port string `json:"port"`
11+
Username string `json:"username"`
12+
Password string `json:"password"`
13+
Timeout string `json:"timeout"`
14+
15+
logger logger.Logger
16+
}
17+
18+
type MilvusProtocolOption func(protocol *MilvusProtocol)
19+
20+
func NewMilvusProtocol(host, port string, logger logger.Logger, opts ...MilvusProtocolOption) *MilvusProtocol {
21+
22+
p := &MilvusProtocol{
23+
Host: host,
24+
Port: port,
25+
logger: logger,
26+
}
27+
for _, opt := range opts {
28+
opt(p)
29+
}
30+
return p
31+
}
32+
33+
func (p *MilvusProtocol) IsInvalid() error {
34+
if p.Host == "" {
35+
p.logger.Error(ErrorInvalidHost, "milvus protocol host is empty")
36+
return ErrorInvalidHost
37+
}
38+
if p.Port == "" {
39+
p.logger.Error(ErrorInvalidPort, "milvus protocol port is empty")
40+
return ErrorInvalidPort
41+
}
42+
return nil
43+
}

0 commit comments

Comments
 (0)