@@ -47,6 +47,7 @@ type CredentialsSecret struct {
4747type Target struct {
4848 Type TargetType
4949 Addr string
50+ Sni string
5051 Credentials Credentials
5152 CredentialsSecret CredentialsSecret
5253 Params map [string ]string
@@ -152,10 +153,17 @@ func (t *Target) StartExporter(reg *prometheus.Registry, credentials Credentials
152153 t .stop = func () {}
153154
154155 case TargetTypeMongodb :
156+ sni := t .Sni
157+ tlsParam := t .Params ["tls" ]
158+ if tlsParam == "" {
159+ tlsParam = "false"
160+ }
155161 collector := mongo .New (
156162 t .Addr ,
157163 credentials .Username ,
158164 credentials .Password ,
165+ tlsParam ,
166+ sni ,
159167 scrapeInterval ,
160168 collectTimeout ,
161169 t .logger ,
@@ -198,6 +206,7 @@ func TargetFromConfig(i config.ApplicationInstrumentation) *Target {
198206 t := & Target {
199207 Type : TargetType (i .Type ),
200208 Addr : net .JoinHostPort (i .Host , i .Port ),
209+ Sni : i .Sni ,
201210 Credentials : Credentials {
202211 Username : i .Credentials .Username ,
203212 Password : i .Credentials .Password ,
@@ -277,6 +286,7 @@ func TargetFromPod(pod *k8s.Pod) *Target {
277286 t = & Target {
278287 Type : TargetTypeMongodb ,
279288 Addr : net .JoinHostPort (pod .IP , cmp .Or (pod .Annotations ["coroot.com/mongodb-scrape-port" ], "27017" )),
289+ Sni : pod .Id .Name ,
280290 Credentials : Credentials {
281291 Username : pod .Annotations ["coroot.com/mongodb-scrape-credentials-username" ],
282292 Password : pod .Annotations ["coroot.com/mongodb-scrape-credentials-password" ],
@@ -287,6 +297,9 @@ func TargetFromPod(pod *k8s.Pod) *Target {
287297 UsernameKey : pod .Annotations ["coroot.com/mongodb-scrape-credentials-secret-username-key" ],
288298 PasswordKey : pod .Annotations ["coroot.com/mongodb-scrape-credentials-secret-password-key" ],
289299 },
300+ Params : map [string ]string {
301+ "tls" : pod .Annotations ["coroot.com/mongodb-scrape-param-tls" ],
302+ },
290303 }
291304 }
292305
0 commit comments