Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
This module provides a "transport" for pino that simply forwards messages to kafka.
You should install pino-kafka
globally for ease of use:
$ npm install --production -g pino-kafka
### or with yarn
$ yarn global add pino-kafka
This library depends on node-rdkafka
.
Have a look at node-rdkafka requirements.
Given an application foo
that logs via pino, and a kafka broker listening on 10.10.10.5:9200
you would use pino-kafka
as:
$ node foo | pino-kafka -b 10.10.10.5:9200
Initialize pino-kafka
and pass it to pino
.
const pino = require('pino')
const pkafka = require('pino-kafka')
const logger = pino({}, pkafka({ brokers: "10.10.10.5:9200"}))
--brokers
(-b
): broker list for kafka producer. Comma seperated hosts--defaultTopic
(-d
): default topic name for kafka.--timeout
(-t
): timeout for initial broker connection in milliseconds. Default 10000--echo
(-e
): echo the received messages to stdout. Default: false.--settings
: path to config JSON file. Have a look at Settings JSON file section for details and examples--kafka.$config
: any kafka configuration can be passed with prefix kafka
. Please visit node-rdkafka configuration for available options.
Note that only producer and global configuration properties will be used.
Have a look at Kafka Settings section for details and examplesThe --settings
switch can be used to specify a JSON file that contains
a hash of settings for the application. A full settings file is:
{
"brokers": "10.6.25.11:9092, 10.6.25.12:9092",
"defaultTopic": "blackbox",
"kafka": {
"compression.codec":"none",
"enable.idempotence": "true",
"max.in.flight.requests.per.connection": 4,
"message.send.max.retries": 10000000,
"acks": "all"
}
}
Note that command line switches take precedence over settings in a settings file. For example, given the settings file:
{
"brokers": "my.broker",
"defaultTopic": "test"
}
And the command line:
$ yes | pino-kafka -s ./settings.json -b 10.10.10.11:9200
The connection will be made to address 10.10.10.11:9200
with the default topic test
.
You can pass node-rdkafka
producer configuration by prefixing the property with kafka.
For example:
$ yes | pino-kafka --kafka.retries=5 --kafka.retry.backoff.ms=500
In the Setting JSON File you can use followings:
{
"kafka": {
"retries": "5",
"retry.backoff.ms": "500"
}
}
Following will work also:
{
"kafka": {
"retries": "5",
"retry":{
"backoff": {
"ms": "500"
}
}
}
}
You can access node-rdkafka
producer from pino stream with _kafka
.
For example:
const pino = require('pino')
const logger = pino({}, pkafka({ brokers: "10.10.10.5:9200"}))
logger[pino.symbols.streamSym]._kafka.getMetadata({}, (err, data)=> {
//...
})
For running tests make sure you installed dependencies with npm install
or yarn
and have a running kafka.
More easily, if you have docker and docker-compose installed, you can create one with following.
$ cd pino-kafka
$ docker-compose up -d
Look at docker-compose file for more details.
After you all setup, just run test command with following:
$ npm run test
# or with yarn
$ yarn test
NOTE: If you use your own kafka setup, you may need to change test configuration accordingly to your needs(ip, topic etc.)
FAQs
A pino 'transport' for writing to kafka
The npm package pino-kafka receives a total of 9 weekly downloads. As such, pino-kafka popularity was classified as not popular.
We found that pino-kafka demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.