i want to retrieve the value from snmptrap input ,
The following log was generated while creating a loop,.
{
"message" => "##enterprise=[1.3.6.1.4.1.9.9.187],#timestamp=##value=2612151602>, #varbind_list=[##name= [1.3.6.1.4.1.9.9.187.1.2.5.1.17.32.1.14.16.255.255.17.0.0.0.0.0.0.0.0.2], #value=\"\x00\x00\">, ##name=[1.3.6.1.4.1.9.9.187.1.2.5.1.3.32.1.14.16.255.255.17.0.0.0.0.0.0.0.0.2], #value=##value=1>>, ##name=[1.3.6.1.4.1.9.9.187.1.2.5.1.28.32.1.14.16.255.255.17.0.0.0.0.0.0.0.0.2], #value=\"\">, ##name=[1.3.6.1.4.1.9.9.187.1.2.5.1.29.32.1.14.16.255.255.17.0.0.0.0.0.0.0.0.2], #value=##value=3>>], #specific_trap=7, #source_ip=\"1.2.3.4\", #agent_addr=##value=\"\xC0\xA8\v\e\">, #generic_trap=6>"
}
i want to retrive the value #source_ip from message , i try to use
mutate {
add_field => { "source_ip" =>["#source_ip"] }
}
to get the #souce_ip and for the new field , but still can't get the value ,
If anyone knows how to do with it , please help. Thanks.
The "#source_ip" information is not a field in what you've shown, but rather part of the [message] field. I would guess that the snmptrap{} input is not entirely happy with the message.
Given the example you have, you could run the message through the grok{} filter to pull out the "#source_ip" information.
I stopped using the snmptrap{} input due to other processing issues. I now run snmptrapd and have it write a json log file that is then read by a simple file{} input in logstash.
Related
I want to display a button on a Sales order only if a custom field on the Sales Order is populated. I have a User Event script (shown below) which runs "before load" to add the button. That part works but I want nlapiLoadRecord to return a record at the "before load" stage so I can check to see if the field is populated or not. I have not been successful in returning a record and I don't know if this is actually possible [?] Can someone help me out?
function BeforeLoad(type, form) {
if (type=='view') {
form.setScript('customscript_instruction_script');
form.addButton("custpage_mybutton", "Instructions", "instruction_click();");
}
}
If you just want to get the value of a field from the actual record that is being loaded, there is no need to call nlapiLoadRecord(). You can simply retrieve the value using nlapiGetFieldValue():
if (type=='view') {
var customFieldValue = nlapiGetFieldValue('custbody_mycustomfield');
if(customFieldValue === "123") {
form.setScript('customscript_instruction_script');
form.addButton("custpage_mybutton", "Instructions", "instruction_click();");
}
}
However if the custom field is from a different record, you will need to retrieve it either by loading that record or running a search. In general nlapiLookupField() would be the most lightweight option.
I have set up an ELK stack on one server and filebeat on 2 other servers to send data directly to logstash.
Setup is working fine and I got log result as per need but when I see field sections on Kibana UI (Left side), I see "host.hostname" field which have two servers fqdns (i.e "ip-113-331-116-35.us-east-1.compute.internal",
"ip-122-231-123-35.us-east-1.compute.internal"
)
I want to set alias or rename those value as Production-1 and Production-2 respectively to show on kibana UI
How can I change those values without breaking anything
If you need any code snippet let me know
You can use the translate filter in the filter block of your logstash pipeline to rename the values.
filter {
translate {
field => "[host][hostname]"
destination => "[host][hostname]"
dictionary => {
"ip-113-331-116-35.us-east-1.compute.internal" => "Production-1"
"ip-122-231-123-35.us-east-1.compute.internal" => "Production-2"
}
}
}
Since the field host.hostname is an ECS-field I would not suggest to rename this particular field.
In my opinion you have two choices:
1.) Create a pipeline in Logstash
You can set up a simple pipeline in Logstash where you use the mutate filter plugin and do a add_field operation. This will create a new field on your event with the value of host.hostname. Here's a quick example:
filter{
if [host][hostname]{
mutate{
add_field => { "your_cool_field_name" => "%{[host][hostname]}" }
}
}
}
2.) Setup a custom mapping/index template
You can define field aliases within your custom mappings. I recommend reading this article about field aliases
My JSON is:
body =
{
"session_id":"45470003-6b84-4a2b-bf35-e850d1e2df8b",
"message":"Thanks for calling service desk, may I know the store number you are calling from?",
"callstatus":"InProgress",
"intent":"",
"responseStatusCode":null,
"responseStatusMsg":null,
"context":"getstorenumber"
}
How to get message value using Node js? Please let me know after testing.
i tried body.message and body['message'] and also body[0]['message']. I am always getting "undefined"
#Chris comment, since the problem is sorted out, Adding the answer to all members for future ref.
From node.js result, body is taken as JSON string, using JSON.parse.body converted to json object.
body =
{
"session_id":"45470003-6b84-4a2b-bf35-e850d1e2df8b",
"message":"Thanks for calling service desk, may I know the store number you are calling from?",
"callstatus":"InProgress",
"intent":"",
"responseStatusCode":null,
"responseStatusMsg":null,
"context":"getstorenumber"
}
JSON.parse.body
console.log(body.message);
I am retrieving JSON data from an API and this is a short example of it:
{"hatenames":
{"id":6239,
"name":"hatenames",
"stat1":659,
"stat2":30,
"stat3":1414693
}
}
I am trying to insert it in the MongoDB (using MongoClient) but it won't let me put just the object directly or use a variable as a field name. If I put the var username it will just output it as username in the database field. This is what I would like to work:
collection.insert({object}
collection.insert({username:object[username]}
but it doesn't and I've been stuck on this for the past few hours. The only resolution I found was to set it and then update the field name afterwards, but that just seems lame to have to do every single time, is there no elegant or easy option that I am somehow missing?
First of all, being a programmer, you should forget about "it does not work" phrase. You should describe how it does not work with exact error messages you encounter. Not to your problem.
Just because I can easily do
db.coll.insert({"hatenames":
{"id":6239,
"name":"hatenames",
"stat1":659,
"stat2":30,
"stat3":1414693
}
})
or var a = {"hatenames":{"id":6239, "name":"hatenames", "stat1":659, "stat2":30, "stat3":1414693}}; and db.coll.insert(a),
I think that the problem is that your object is not really an object, but a string. So I suspect that you have a string returned to you back from that API. Something like '{"hatenames":{...}' and this caused a problem when you try to save it or access the properties. So try to convert it to JSON.
Try doing this:
MongoClient.connect('mongodb://127.0.0.1:27017/db_name', function(err, db) {
if(err) throw err;
someCollection = db.collection('some_collection');
});
someCollection.insert({
name: hatenames['name']
});
EDIT
For Dynamic approach, I would suggest you to play aroung this function:
Object.keys(hatenames)
this function will return keys in array.
EDIT 2
I have founded a link: Insert json file into mongodb using a variable
See, if that helps.
I am have a webservice which services GET requests of the following pattern
/v1/stores?name=<>&lat=23&lng=232....
There a number of query parameters which the request can accept. Is it possible to get url specific information kibana through log stash on kibana.What I really want is a average number of requests for each pattern along with their max, min and avg response types.I would also
You would want something like this as part of your logstash.conf:
grok {
// some pattern that extracts out the uri param (everything after ?) into a param field
}
kv {
source => 'param'
field_split => '&'
}
// you might also need to urldecode {} the parameters