$msg contains "test" filter is not dropping events - rsyslog

I'm attempting to drop events that contain certain text. I've tried a few different ways, but the events still keep being written to disk.
Here's what I'm trying to do:
drop.conf
ruleset (name="test_sort") {
if ($msg contains "test") then {
stop
} else {
set $!host=$$myhostname;
action(type="omfile" dynafile="format")
stop
}
}
input (type="impudp" port="5000" ruleset="test_sort")
I've also tried the following:
:msg, contains, "test" stop
Am I missing something?

Related

How To Save Settings in Qt

I wrote some codes for an application
and I want to save this Settings Like Hide a lineEdit or etc...
and when reopen program last settings will load and when user edit setting
settings that saved updates
what I must do?
note: I Used Qsettings but settings dose not saved!
if Possible one person Write a Sample Code For me That save current index of a combobox
QSettings settings("Mobtakeran Fanavri KabooK","Kabook Physiothrapy");
Secretary::Secretary(QWidget *parent) :
QWidget(parent),
ui(new Ui::Secretary)
{
ui->setupUi(this);
ui->comboBox->setCurrentIndex(settings.value("comboBox").toInt());
}
Secretary::~Secretary()
{
QCoreApplication::setOrganizationName("Mobtakeran Fanavri KabooK");
QCoreApplication::setOrganizationName("WWW.M4RZB4Ni.IR");
QCoreApplication::setApplicationName("Kabook Physiothrapy");
delete ui;
}
void Secretary::on_comboBox_currentIndexChanged(int index)
{
settings.beginGroup("comboBox");
if(ui->comboBox->currentIndex()==2) {
ui->pushButton_3->setDisabled(true);
} else if(ui->comboBox->currentIndex()==1) {
ui->pushButton_3->hide();
settings.setValue("comboBox",ui->comboBox->currentIndex());
} else if(ui->comboBox->currentIndex()==0) {
if(ui->lineEdit_56->text()==NULL) {
ui->pushButton_8->setDisabled(true);
}
}
settings.endGroup();
}
when you are saving your settings in Secretary::on_comboBox_currentIndexChanged you are calling settings.beginGroup("comboBox") then you set the value settings.setValue("comboBox",ui->comboBox->currentIndex()).
According to the documentation, this will set the value of the settings "comboBox/comboBox", meaning that you should read its value using settings.value("comboBox/comboBox").toInt().
Also please note that you are calling settings.setValue only in the case where currentIndex changes to 2, are you sure you mean to do that? didn't you mean to call it after all your if/else blocks?

Filter specific Message with logstash before sending to ElasticSearch

I had like to know if it is possible to send only specific log messages to elasticsearch via logstash? E.G let's say I have these messages in my log file:
2015-08-14 12:21:03 [31946] PASS 10.249.10.70 http://google.com
2015-08-14 12:25:00 [2492] domainlist \"/etc/ufdbguard/blacklists\
2015-08-14 12:21:03 [31946] PASS 10.249.10.41 http://yahoo.com
I had like to skip the second line when logstash/log forwarder process this log, is it possible to instruct it to skip any log message with the keyword 'domainlist'? Or allow only log messages with the keyword 'PASS'?
Yes, you can achieve that by using the drop filter.
Depending on how you grok your log line and which field names you have, you can decide to drop an event if it matches some criteria. For instance, below you can see a conditional after the grok filter, which checks whether myfield contains something different than the value PASS in which case it will drop the event.
filter {
grok {
...your parsing regexp here...
}
if [myfield] != "PASS" {
drop { }
}
}
Although Val's answer is correct, another way you can do it is by filtering with a conditional:
output {
if "PASS" in [message] {
elasticsearch {
...
}
}
}

Why is custom message not working in grails when tried with the following?

i am a beginner in grails and i have the following problem. Please help.
package racetrack
class Users {
String userName
String password
static constraints = {
userName(nullable:false, maxSize:20)
password(password:true, minSize: 8,
validator: {
return (it.matches("(.*[\\d])"))?true: ['noNumber']
return (it.matches("(.*[\\W])"))?true: ['noSpecialCh']
return (it.matches("(.*[a-z])"))?true: ['noLower']
return (it.matches("(.*[A-Z])"))?true: ['noUpper']
}
)
}
}
I created the above domain and in message.properties, i added the following:
users.password.validator.noNumber=should contain at least one number
users.password.validator.noLower=should contain at least one lower case letter as well
users.password.validator.noUpper=should contain number as well
users.password.validator.noSpecialCh=should contain number as well
however, i am not given required messages when tried with faulty values. Suppose, if i give no number in the password "should contain at least one number" message was expected but i only get does not match custom validation message.
The core problem is that Groovy, unlike Java, allows multiple return statements. If you converted that to Java it wouldn't compile.
Groovy allows multiple return statements, but obviously only considers the first, so with your code you have one check, not four, essentially
(it.matches("(.*[\\d])")) ? true : ['noNumber']
It should be something like this:
if (!it.matches("(.*[\\d])")) {
return ['noNumber']
}
if (!it.matches("(.*[\\W])")) {
return ['noSpecialCh']
}
if (!it.matches("(.*[a-z])")) {
return ['noLower']
}
if (!it.matches("(.*[A-Z])")) {
return ['noUpper']
}
except that all of the regexes are broken, but that's a separate issue.

Add empty row with message "No results found"

When there's no data I want SlickGrid to display a message that states something like "No results found". Any way of doing that? I can't find it in the docs.
In the end I hacked it a bit like the following (data is loaded via ajax following the example they have at "example6-ajax-loading.html"):
loader.onDataLoaded.subscribe(function (e, args) {
// check if there's any data in the data array
....
if (!anyData) {
grid.invalidateAllRows();
$('.grid-canvas').html('<div>No Data.</div>');
return;
}
}

Restrict Google Places Autocomplete to return addresses only

autocomplete = new google.maps.places.Autocomplete(input, { types: ['geocode'] });
returns streets and cities amongst other larger areas. Is it possible to restrict to streets only?
This question is old, but I figured I'd add to it in case anyone else is having this issue. restricting types to 'address' unfortunately does not achieve the expected result, as routes are still included. Thus, what I decided to do is loop through the result and implement the following check:
result.predictions[i].types.includes('street_address')
Unfortunately, I was surprised to know that my own address was not being included, as it was returning the following types: { types: ['geocode', 'premise'] }
Thus, I decided to start a counter, and any result that includes 'geocode' or 'route' in its types must include at least one other term to be included (whether that be 'street_address' or 'premise' or whatever. Thus, routes are excluded, and anything with a complete address will be included. It's not foolproof, but it works fairly well.
Loop through the result predictions, and implement the following:
if (result.predictions[i].types.includes('street_address')) {
// Results that include 'street_address' should be included
suggestions.push(result.predictions[i])
} else {
// Results that don't include 'street_address' will go through the check
var typeCounter = 0;
if (result.predictions[i].types.includes('geocode')) {
typeCounter++;
}
if (result.predictions[i].types.includes('route')) {
typeCounter++;
}
if (result.predictions[i].types.length > typeCounter) {
suggestions.push(result.predictions[i])
}
}
I think what you want is { types: ['address'] }.
You can see this in action with this live sample: https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete (use the "Addresses" radio button).

Resources