-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vitor Nascimento Jr
committed
Feb 23, 2017
0 parents
commit 6415227
Showing
2 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import com.dtolabs.rundeck.plugins.notification.NotificationPlugin | ||
import com.dtolabs.rundeck.core.plugins.configuration.StringRenderingConstants | ||
import com.dtolabs.rundeck.core.plugins.configuration.ValidationException | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import groovy.json.JsonOutput | ||
|
||
/** | ||
* Send Log. | ||
* @param execution the execution data map | ||
* @param config the plugin configuration data map | ||
*/ | ||
def sendNotification(Map execution, Map config) { | ||
|
||
// Socket | ||
def socket = new Socket(config.host, config.port.toInteger()); | ||
def socketStream = socket.getOutputStream(); | ||
|
||
// Execution Information | ||
def e2 = [:] | ||
execution.each{ e2["${it.key}"] = it.value } | ||
|
||
// Stream | ||
def json = new ObjectMapper() | ||
socketStream << json.writeValueAsString(e2 + data) + "\n" | ||
} | ||
|
||
rundeckPlugin(NotificationPlugin) { | ||
title = 'Logstash Notification' | ||
description = 'Send Execution Results to LogStash' | ||
configuration { | ||
host required: true, description: "Hostname to connect to Logstash", scope: 'Framework' | ||
port required: true, description: "Port to connect to Logstash", type: 'Integer', scope: 'Framework' | ||
} | ||
|
||
onstart { Map executionData, Map configuration -> | ||
sendNotification(executionData, configuration) | ||
true | ||
} | ||
|
||
onfailure { Map executionData, Map configuration -> | ||
sendNotification(executionData, configuration) | ||
true | ||
} | ||
|
||
onsuccess { Map executionData, Map configuration -> | ||
sendNotification(executionData, configuration) | ||
true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
Info: Script inspired from https://github.com/rundeck-plugins/rundeck-logstash-plugin. | ||
|
||
# Rundeck Logstash Notification Plugin | ||
|
||
This is a simple Rundeck Notifiction plugin that will pipe all executions logs to a Logstash server by writing Json to a TCP port. *For Rundeck version 2.6.x or later.* | ||
|
||
# Installation | ||
|
||
Copy the `Logstash.groovy` to your `$RDECK_BASE/libext/` directory for Rundeck. | ||
|
||
# Configure Rundeck | ||
|
||
The plugin supports these configuration properties: | ||
|
||
* `host` - hostname of the logstash server | ||
* `port` - TCP port to send JSON data to | ||
|
||
You can update the your framework.properties file to set these configuration values: | ||
|
||
in `framework.properties`: | ||
|
||
framework.plugin.Notification.Logstash.port=5000 | ||
framework.plugin.Notification.Logstash.host=localhost | ||
|
||
# Configure Logstash | ||
|
||
Add a TCP input that uses Json format data. Here is an example `rundeck-logstash.conf`: | ||
|
||
output { | ||
stdout { } | ||
elasticsearch { | ||
embedded => true | ||
} | ||
} | ||
|
||
input { | ||
tcp { | ||
port => 5000 | ||
} | ||
} | ||
|
||
filter{ | ||
mutate { | ||
replace => { | ||
"type" => "rundeck" | ||
} | ||
} | ||
json { | ||
source => "message" | ||
target => "rundeck" | ||
} | ||
} | ||
|
||
## Or add your filters / logstash plugins configuration here | ||
|
||
output { | ||
elasticsearch { | ||
hosts => "elasticsearch:9200" | ||
} | ||
} | ||
|
||
|
||
# Start Logstash | ||
|
||
Use the config file when starting logstash. | ||
|
||
https://hub.docker.com/_/logstash/ |