Drupal Integration
Lets setup a listener such that Drupal can easily output to for avoiding DB writes like dblog or access logs and others.
The code in Drupal should do something like this:
function output_to_fluentd($port, $obj) {
global $cookie_domain;
if (is_array($obj)) {
$obj['domain'] = $cookie_domain;
}
else if (is_object($obj)) {
$obj->domain = $cookie_domain;
}
$in = drupal_json_encode($obj) . "\n";
try {
$fp = fsockopen("udp://127.0.0.1", $port, $errno, $errstr);
if ($fp) {
$w = fwrite($fp, $in);
fclose($fp);
if ($w == strlen($in)) {
return TRUE;
}
}
}
catch (Exception $ex) {
// Ignore silently
}
return FALSE;
}
In FluentD wie simply needs this:
fluentd_applications:
- plugin: 'elasticsearch_dynamic'
port: 20001
index: 'messages'
type: "${record['domain']}"
extras:
- 'id_key cid'
Edited by Jürgen Haas