Logstash with IRC is not seem to be working - logstash

I am trying to grab messages from IRC with Logstash, but I am not getting anything. Here is my config file:
input {
irc {
channels => ["#logstash"]
host => "irc://irc.freenode.net"
user => "abcde"
}
}
filter {
}
output {
stdout {}
}
Is there something I am missing?
Here is the documentation on that plugin for Logstash:
https://www.elastic.co/guide/en/logstash/current/plugins-inputs-irc.html
I am using Logstash 1.5.5.

Related

Store channel id with command

I'm working on a discord.js v13 bot and I want to make a commmand that stores the channel id the command sent in then, A command that works only the channels stored .
I want an example of the code to do this :)
I didn't try bec I can't realize how to do it :)
It's pretty easy when you know how to do it actually. You can listen on messages in different channels with:
client.on("message", (message) => {
console.log(`Channel-ID: ${message.channel.id}`);
});
See the Docs: Message
I don't know if it works in v13 but if not try this:
client.on("message", (message) => {
console.log(`Channel-ID: ${message.channelId}`);
});
To react when a command is used:
client.on("message", (message) => {
if(message.startsWith("!channel")){
console.log(`Channel-ID: ${message.channelId}`);
}
});

'"file" argument must be a non-empty string' error when using playStream()

I am encountering a problem with the playStream() function.
The stream does not play and I get the following error:
"file" argument must be a non-empty string
And yes, I am sure that args[0] is defined as 'youtube.com/watch?v=A02s8omM_hI' and stream logs as a PassThrough (console).
var stream = ytdl(args[0], { filter: "audioonly" });
message.member.voiceChannel.join().then(connection => {
const dispatcher = connection.playStream(stream);
dispatcher.on("error", (error) => {
console.log(error);
});
dispatcher.on("end", () => {
console.log("Song ended!");
});
});
Unfortunately, I couldn't find any solutions on the internet related to my problem.
Thanks in advance!
Maybe you've passed an empty string as a output file?
docs:
-o FILE, --output FILE Save to file, template by {prop}, default: stdout

Rabbit MQ amqplib error "No channels left to allocate"

After working the rabbit mq workers in pub sub pattern for some time i am getting an error in creating an channel.
Error: No channels left to allocate
If you are using https://www.npmjs.com/package/amqplib,
you can use Promise to share a channel while publishing multiple messages
in message-queue.js
const q = 'tasks';
const open = require('amqplib').connect('amqp://localhost');
const channelPromise = open.then((conn) => conn.createChannel());
// Publisher
function publishMessage(message) {
channelPromise.then((ch) => ch.assertQueue(q)
.then((ok) => ch.sendToQueue(q, Buffer.from(message))))
.catch(console.warn);
}
// Consumer
open.then((conn) => conn.createChannel())
.then((ch) => ch.assertQueue(q).then((ok) => ch.consume(q, (msg) => {
if (msg !== null) {
console.log(msg.content.toString());
ch.ack(msg);
}
}))).catch(console.warn);
module.exports = {
publishMessage,
};
some-where.js
messageQueue.publishMessage('hello world')
The maximum number of channels you can allocate is negotiated with rabbitmp server. In my server, this value is 2047. You can debug you amqplib/lib/connection.js to get this.

Bad GET URL when using the Logstash http_poller input plugin

Trying to pull data from a public API using the Logstash http_poller input plugin:
input {
http_poller {
urls => {
method => "GET"
url => "https://api.example.com/v1/service/"
}
request_timeout => 60
schedule => { cron => "0 * * * *"}
codec => "json"
metadata_target => "http_poller_metadata"
}
}
filter {
}
output {
elasticsearch {
hosts => ["localhost:9200"]
}
}
Keep on getting a bad get URL error:
[ERROR][logstash.pipeline] Pipeline aborted due to error {:pipeline_id=>"main", :exception=>#<LogStash::ConfigurationError: Invalid URL GET>...]
Any idea what's causing this? The URL for the API is correct...
Turns out it was the method => "GET" line. Removing it worked like a charm.

websocket interrupted while angular2 project is loading on firefox

I've just started angular 2. I've done an angular2 sample as given in the https://angular.io/guide/quickstart
when I run the project in Firefox using
npm start
command in terminal, the connection get disconnected after output showing once.Error showing like
The connection to ws://localhost:3000/browser-sync/socket.io/?EIO=3&transport=websocket&sid=6YFGHWy7oD7T7qioAAAA was interrupted while the page was loading
Any idea about how to fix this issue ?
I don't know how you manage your web socket but you could consider using the following code. This idea is to wrap the web socket into an observable.
For this you could use a service like below. The initializeWebSocket will create a shared observable (hot) to wrap a WebSocket object.
export class WebSocketService {
initializeWebSocket(url) {
this.wsObservable = Observable.create((observer) => {
this.ws = new WebSocket(url);
this.ws.onopen = (e) => {
(...)
};
this.ws.onclose = (e) => {
if (e.wasClean) {
observer.complete();
} else {
observer.error(e);
}
};
this.ws.onerror = (e) => {
observer.error(e);
}
this.ws.onmessage = (e) => {
observer.next(JSON.parse(e.data));
}
return () => {
this.ws.close();
};
}).share();
}
}
You could add a sendData to send data on the web socket:
export class WebSocketService {
(...)
sendData(message) {
this.ws.send(JSON.stringify(message));
}
}
The last point is to make things a bit robust, i.e. filter received messages based on a criteria and implement retry when there is a disconnection. For this, you need to wrap our initial websocket observable into another one. This way we can support retries when the connection is lost and integrate filtering on criteria like the client identifier (in the sample the received data is JSON and contains a sender attribute).
export class WebSocketService {
(...)
createClientObservable(clientId) {
return Observable.create((observer) => {
let subscription = this.wsObservable
.filter((data) => data.sender!==clientId)
.subscribe(observer);
return () => {
subscription.unsubscribe();
};
}).retryWhen((errors) => {
return Observable.timer(3000);
});
}
}
You can see that deconnections are handled in this code using the retryWhen operator of observable.

Resources