How to Combine the First and Last Name fields into a new field logstash? - logstash-json

Sample Data : {
"_id": "5c53d41e80e3f817d9cec5b0",
"index": 0,
"account_number": 1623,
"balance": 22526.72,
"firstname": "Desiree",
"lastname": "Mays",
"age": 46,
"gender": "female",
"address": "931 Metropolitan Avenue, Faxon, Oregon, 3046",
"employer": "IDEGO",
"email": "desireemays#idego.com",
"city": "Rodanthe",
"state": "Tennessee"
}
Conf File:
input {
file {
type => "json"
path=>'path'
}}filter { json {source => "message"} mutate {add_field => { "field_name" => "%{Firstname}" "%{lastname}"}}}output {
file {
path =>'path'
}}
I Keep on getting the tag _jsonparsefailure

Could you confirm if the input file is a JSON type and if the path is set appropriately? otherwise i don't see an anomaly with add_field syntax here.

Related

Postman post form data as json object

I have this json data
{
"title":"title",
"description":"title",
"floor": 1,
"floor_count": 10,
"address" : {
"street": "street",
"house_no": "8/1",
"door_no": "10",
"city":"Horsens",
"country": "Denmark",
"postal_code":8700
},
"report": null
}
I want the report to include some file fields, to post files is achievable using form-data
but using form data to post files wont count those files as a report fields.
{
"title":"title",
"description":"title",
"floor": 1,
"floor_count": 10,
"address" : {
"street": "street",
"house_no": "8/1",
"door_no": "10",
"city":"Horsens",
"country": "Denmark",
"postal_code":8700
},
"report": {
"file1": file1,
"file2": file2,
}
}
I am trying like this, no success

Search for field name ends with

I am new to OData and I have a scenario to search for field name that contains words I am looking for. Below is the data I would like to search for the field name that ends with _isApproved. I am not sure if it possible to do such search.
[
{
"name": "John",
"address": "123 Example Dr.",
"city": "Frederick",
"zipcode": 654334,
"extension_345435423_isApproved": true
},
{
"name": "Smith",
"address": "124 Example Dr.",
"city": "Frederick",
"zipcode": 654374
}
]

Cannot create contact with email address

Posting to this endpoint https://graph.microsoft.com/beta/me/contacts with this payload:
{
"displayName": "test",
"givenName": "test",
"emailAddresses": {
"address": "test#test.com",
"name": "test"
}
}
Results in an error:
Property emailAddresses in payload has a value that does not schema
As far as I can tell this is correct according to the emailAddress resource type https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/emailaddress
clearly I'm doing it wrong, but I don't know what needed to be changed.
Your JSON syntax is off. emailAddresses is a collection, so you need square parentheses. Try something like:
{
{
"displayName": "test",
"givenName": "test",
"emailAddresses": [
{
"address": "test#test.com",
"name": "test"
}
]
}
}
Hope this helps,

fill a JSON file with embedded arrays from Rails

I have a simple "rss" (ApplicationRecord) table indexed by an id. I would like to have a structured JSON that group each user from a family in an array structure. And then each family in a global array. How can I do that ?
my current plain code to put my data in a json file is :
json.rss #rss do |rs|
json.id rs.id
json.name rs.name
json.family rs.family
json.lastdate rs.lastdate
json.last rs.last
json.s1w rs.s1w
json.s2w rs.s2w
end
But the target file that I want is this one :
{
"rss": [
{
"familyname": "Smith",
"children": [
{
"id": "1",
"name": "bob",
"lastdate": "2010-09-23",
"last": "0.88",
"s1w": "0.83",
"s2w": "0.88"
},
{
"id": 2,
"name": "Mary",
"lastdate": "2011-09-23",
"last": "0.89",
"s1w": "0.83",
"s2w": "0.87"
}
]
},
{
"familyname": "Wesson",
"children": [
{
"id": "1",
"name": "john",
"lastdate": "2001-09-23",
"last": "0.88",
"s1w": "0.83",
"s2w": "0.88"
},
{
"id": 2,
"name": "Bruce",
"lastdate": "2000-09-23",
"last": "0.89",
"s1w": "0.83",
"s2w": "0.87"
}
]
}
]
}
The grouping you are trying to achieve can be done in Ruby with:
#rss.group_by(&:family).values
This is assuming #rss is an array-like collection of objects that have a .family method. The result: is an array of arrays of objects grouped by family.
Now it will be up to use to use Jbuilder's array! method to build the desired JSON output.

Avro java serialization as json not working correctly

I have a simple avro schema, from which I generated a java class using the avro-maven-plugin.
The avro schema is as follows:
{
"type": "record",
"name": "addressGeo",
"namespace": "com.mycompany",
"doc": "Best record address and list of geos",
"fields": [
{
"name": "version",
"type": "int",
"default": 1,
"doc": "version the class"
},
{
"name": "eventType",
"type": "string",
"default": "addressGeo",
"doc": "event type"
},
{
"name": "parcelId",
"type": "long",
"doc": "ParcelID of the parcel. Join parcelid and sequence with ParcelInfo"
},
{
"name": "geoCodes",
"type": {"type": "array", "items": "com.mycompany.geoCode"},
"doc": "Multiple Geocodes, with restrictions information"
},
{
"name": "brfAddress",
"type": ["null", "com.mycompany.address"],
"doc": "Address cleansed version of BRF"
}
]
}
If I construct a simple object using the builder, and serialize it using json, I get the following output:
{
"version": 1,
"eventType": {
"bytes": [
97,
100,
100,
114,
101,
115,
115,
71,
101,
111
],
"length": 10,
"string": null
},
"parcelId": 1,
"geoCodes": [
{
"version": 1,
"latitude": 1,
"longitude": 1,
"geoQualityCode": "g",
"geoSourceTypeID": 1,
"restrictions": "NONE"
}
],
"brfAddress": {
"version": 1,
"houseNumber": "1",
"houseNumberFraction": null,
"streetDirectionPrefix": null,
"streetName": "main",
"streetSuffix": "street",
"streetDirectionSuffix": null,
"fullStreetAddress": "1 main street, seattle, wa, 98101",
"unitPrefix": null,
"unitNumber": null,
"city": "seattle",
"state": "wa",
"zipCode": "98101",
"zipPlusFour": null,
"addressDPV": "Y",
"addressQualityCode": "good",
"buildingNumber": "1",
"carrierRoute": "t",
"censusTract": "c",
"censusTractAndBlock": "b",
"dataCleanerTypeID": 1,
"restrictions": "NONE"
}
}
Note the output of the eventType field. It is coming through as an array of bytes whereas the type of the field is a CharSequence.
Any idea why serialization is doing this? It works fine for other types that are strings.
I am using google-gson to serialize the object to json.
You might be working with a older version of avro, that uses CharSequence. Ideally string type should be java String type. I would suggest to update the avro version or have a look at this one - Apache Avro: map uses CharSequence as key

Resources