From 58b4b9e677b5da338894b6a04e52bd2abaec060e Mon Sep 17 00:00:00 2001 From: Lewis Marshall Date: Fri, 9 May 2014 02:18:14 +0100 Subject: [PATCH] Support Elasticsearch Basic Auth --- README.md | 4 ++++ packetbeat.conf | 4 ++++ publish.go | 8 ++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 99a2b306a03e..ae043e752d56 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,10 @@ First, set the IP address and port where the agent can find the Elasticsearch in # Set the host and port where to find Elasticsearch. host = "192.168.1.42" port = 9200 + + # Optional basic auth credentials + # username = "admin" + # password = "s3cr3t" ``` Select the network interface from which to capture the traffic. Packetbeat supports capturing all messages sent or received by the server on which it is installed. For this, use "any" as the device: diff --git a/packetbeat.conf b/packetbeat.conf index 92eb55083027..3ea2918cf133 100644 --- a/packetbeat.conf +++ b/packetbeat.conf @@ -13,6 +13,10 @@ host = "localhost" port = 9200 +# Optional basic auth credentials +# username = "admin" +# password = "s3cr3t" + [interfaces] # Select on which network interfaces to sniff. You can use the "any" # keyword to sniff on all connected interfaces. diff --git a/publish.go b/publish.go index cad87d941f49..9550864c8366 100644 --- a/publish.go +++ b/publish.go @@ -27,8 +27,10 @@ type tomlAgent struct { Refresh_topology_freq int } type tomlMothership struct { - Host string - Port int + Host string + Port int + Username string + Password string } type Event struct { @@ -264,6 +266,8 @@ func (publisher *PublisherType) Init() error { // Set the Elasticsearch Host to Connect to api.Domain = _Config.Elasticsearch.Host api.Port = fmt.Sprintf("%d", _Config.Elasticsearch.Port) + api.Username = _Config.Elasticsearch.Username + api.Password = _Config.Elasticsearch.Password INFO("Use %s:%s as publisher", api.Domain, api.Port)