Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
telegraf-nftables
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Due to inactivity, this project is scheduled to be deleted on 2035-04-24.
Why is this scheduled?
Show more breadcrumbs
vqgroup
telegraf-nftables
Commits
7a5d8578
Commit
7a5d8578
authored
8 years ago
by
Daniel Nelson
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add support for new SSL configuration to mongodb (#2522)
closes #2519
parent
13f314a5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
plugins/inputs/mongodb/README.md
+8
-1
8 additions, 1 deletion
plugins/inputs/mongodb/README.md
plugins/inputs/mongodb/mongodb.go
+28
-1
28 additions, 1 deletion
plugins/inputs/mongodb/mongodb.go
with
37 additions
and
2 deletions
CHANGELOG.md
+
1
−
0
View file @
7a5d8578
...
...
@@ -57,6 +57,7 @@ be deprecated eventually.
-
[
#2071
](
https://github.com/influxdata/telegraf/issues/2071
)
: Use official docker SDK.
-
[
#1678
](
https://github.com/influxdata/telegraf/pull/1678
)
: Add AMQP consumer input plugin
-
[
#2501
](
https://github.com/influxdata/telegraf/pull/2501
)
: Support DEAD(X) state in system input plugin.
-
[
#2522
](
https://github.com/influxdata/telegraf/pull/2522
)
: Add support for mongodb client certificates.
### Bugfixes
...
...
This diff is collapsed.
Click to expand it.
plugins/inputs/mongodb/README.md
+
8
−
1
View file @
7a5d8578
...
...
@@ -11,9 +11,16 @@
## 10.0.0.1:10000, etc.
servers
=
[
"127.0.0.1:27017"
]
gather_perdb_stats
=
false
## Optional SSL Config
# ssl_ca = "/etc/telegraf/ca.pem"
# ssl_cert = "/etc/telegraf/cert.pem"
# ssl_key = "/etc/telegraf/key.pem"
## Use SSL but skip chain & host verification
# insecure_skip_verify = false
```
For authenticated mongodb istances use
connection
mongdb connection URI
For authenticated mongodb i
n
stances use
`
mong
o
db
://`
connection URI
```
toml
[[inputs.mongodb]]
...
...
This diff is collapsed.
Click to expand it.
plugins/inputs/mongodb/mongodb.go
+
28
−
1
View file @
7a5d8578
...
...
@@ -10,6 +10,7 @@ import (
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs"
"gopkg.in/mgo.v2"
...
...
@@ -20,6 +21,15 @@ type MongoDB struct {
Ssl
Ssl
mongos
map
[
string
]
*
Server
GatherPerdbStats
bool
// Path to CA file
SSLCA
string
`toml:"ssl_ca"`
// Path to host cert file
SSLCert
string
`toml:"ssl_cert"`
// Path to cert key file
SSLKey
string
`toml:"ssl_key"`
// Use SSL but skip chain & host verification
InsecureSkipVerify
bool
}
type
Ssl
struct
{
...
...
@@ -35,6 +45,13 @@ var sampleConfig = `
## 10.0.0.1:10000, etc.
servers = ["127.0.0.1:27017"]
gather_perdb_stats = false
## Optional SSL Config
# ssl_ca = "/etc/telegraf/ca.pem"
# ssl_cert = "/etc/telegraf/cert.pem"
# ssl_key = "/etc/telegraf/key.pem"
## Use SSL but skip chain & host verification
# insecure_skip_verify = false
`
func
(
m
*
MongoDB
)
SampleConfig
()
string
{
...
...
@@ -105,8 +122,11 @@ func (m *MongoDB) gatherServer(server *Server, acc telegraf.Accumulator) error {
dialInfo
.
Direct
=
true
dialInfo
.
Timeout
=
5
*
time
.
Second
var
tlsConfig
*
tls
.
Config
if
m
.
Ssl
.
Enabled
{
tlsConfig
:=
&
tls
.
Config
{}
// Deprecated SSL config
tlsConfig
=
&
tls
.
Config
{}
if
len
(
m
.
Ssl
.
CaCerts
)
>
0
{
roots
:=
x509
.
NewCertPool
()
for
_
,
caCert
:=
range
m
.
Ssl
.
CaCerts
{
...
...
@@ -119,6 +139,13 @@ func (m *MongoDB) gatherServer(server *Server, acc telegraf.Accumulator) error {
}
else
{
tlsConfig
.
InsecureSkipVerify
=
true
}
}
else
{
tlsConfig
,
err
=
internal
.
GetTLSConfig
(
m
.
SSLCert
,
m
.
SSLKey
,
m
.
SSLCA
,
m
.
InsecureSkipVerify
)
}
// If configured to use TLS, add a dial function
if
tlsConfig
!=
nil
{
dialInfo
.
DialServer
=
func
(
addr
*
mgo
.
ServerAddr
)
(
net
.
Conn
,
error
)
{
conn
,
err
:=
tls
.
Dial
(
"tcp"
,
addr
.
String
(),
tlsConfig
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment