could please someone explain to me, why logstash keeps ignoring "codec => plain => format" setting, I am trying to set?
Cfg file I am using:
input {
gelf {
host => "[some ip]"
port => 12201
}
}
output {
elasticsearch {
host => "[some ip]"
bind_port => "9301"
}
file {
codec => plain {
format => "%{[time]} | %{[severity]} : /%{[thread]}/ %{[loggername]} (%{[sourcemethodname]}) - %{[message]}"
}
path => "/Users/[some user]/logs/%{host}/%{facility}-%{+YYYY-MM-dd}.log"
}
}
I thought I used the wrong format, tried different combinations like "%{time}" for fields and even tried to use constant text like:
codec => plain {format => "Simple line"}
But nothing seems to work. It outputs to the elasticsearch fine, create folder/files, but outputs it as JSON.
If anyone knows what is going on with it, please help.
Thanks.
Parameter message_format is deprecated and will be remove in future relases of Logstash. Instead of using message_format try something like this:
file {
codec => line {
format => "%{[time]} | %{[severity]} : /%{[thread]}/ %{[loggername]} (%{[sourcemethodname]}) - %{[message]}"
}
path => "/Users/[some user]/logs/%{host}/%{facility}-%{+YYYY-MM-dd}.log"
}
PS: your example using codec plain, try my with line.
file has a message_format parameter that is what you'll want to use:
file {
message_format => "%{[time]} | %{[severity]} : /%{[thread]}/ %{[loggername]} (%{[sourcemethodname]}) - %{[message]}"
path => "/Users/[some user]/logs/%{host}/%{facility}-%{+YYYY-MM-dd}.log"
}
Related
I want the table name to be today's date.
For example: dbtest_2022.dbo.tbshop2_2022_08_22 auto change to dbtest_2022.dbo.tbshop2_2022_08_23
input {
jdbc {
jdbc_driver_library => "/usr/share/logstash/logstash-core/lib/jars/sqljdbc42.jar"
jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc_connection_string => "..."
jdbc_user => "..."
jdbc_password => "..."
statement => "SELECT ... FROM dbtest_2022.dbo.tbshop2_2022_08_22"
schedule => "*/14 * * * *"
add_field => { "tag" => "mssql-test" }
type => "mssql"
}
}
I had an idea to make two requests.
In the first request, get the table id and in the second, make a request with this id.
statement => "SELECT OBJECT_ID(N'dbtest_2022.dbo.tbshop2_{year}_{month}_{day}') AS 'object_id' AND SELECT ... FROM table(object_id)"
or is there any expression in jdbc to implement this?
For example: dbtest_2022.dbo.tbshop2_now()
or can I use dbtest_2022.dbo.tbshop2_{year}{month}{day} in jdbc ?
Well, so that every day you don’t change the request with your hands, but somehow automate it
I am not very good at SQL. I would be glad for help or ideas on how to implement this.
I solutioned with below steps.
1. [.profile] set Envoronment variable.
...
CURRENT_YYYYMM=`date "+%Y%m`
export CURRENT_YYYYMM
...
2. logstash config file
input {
jdbc {
...
FROM ${CURRENT_YYYYMM}_logs
...
}
reference :
https://www.elastic.co/guide/en/logstash/current/environment-variables.html
I am using react-table v7, useExportData and papaparse to download a .csv from a table referencing to this codesandbox, so far it downloaded successfully but I can't find a way to name a file to download. My code is following
function getExportFileBlob({ columns, data, fileType, fileName }) {
if (fileType === "csv") {
// CSV example
const headerNames = columns.map((col) => col.exportValue);
const csvString = Papa.unparse({ fields: headerNames, data });
return new Blob([csvString], { type: "text/csv" });
}
You can use the getExportFileName function defined in the docs and overwrite the default all-data.fileType or data.fileType name.
by returning a name for your exported data. Check out the following sandbox!
Hope this helps.
`
Probably too late, but for those seeking for an answer, according to docs,
getExportFileName: Function({ fileType, all }) => string
is the function you need to override the default file name.
I believe you can access it from main useTable where you are passing this plugin:
const {
....
exportData,
} = useTable(
{
getExportFileName: ({ all }) => {
return `${all ? 'exported-all' : 'current-view-only'}` // <--- there
},
},
useExportData
)
check it out, hope this helps!
i am using ibm watson-speech-to-text.
i am getting the text output related to the audio.
My question is is it possible to get the audio file from it ?
Here my code
var recognizeMic = require('watson-speech/speech-to-text/recognize-
microphone')
var stream = recognizeMic({
access_token: this.state.watsonAccessToken,
outputElement: '#output',
})
stream.on('data', async (data: any) => {
this.state.recognizedText= data.results[0].alternatives[0].transcript;
}
can anyone help me how i get the speech ?
My data is stored in Elasticsearch and I need a way to pull it and use SPSS with.
Is there any method for this? Maybe a connector layer of programming I need to do on SPSS?
Thanks in adv
The easiest way I see is to use Logstash to export your data from ES into a CSV file and then import that CSV into SPSS.
A sample Logstash config file to export your data would look like this:
input {
elasticsearch {
hosts => ["localhost:9200"]
query => '{"query":{"match_all":{}}'
index => "my-index"
scroll => "5m"
}
}
filter {
mutate {
remove_field => [ "#version", "#timestamp" ]
}
}
output {
csv {
fields => ["header1", "header2", "header3"]
path => "my-index.csv"
}
}
Is it possible to save an image to the android's local file system so it can be viewed from the phone's 'Gallery' and in a folder??
I found this react-native-fs library but after studying the documentation and working through an example I am still unsure if it is possible.
Thanks
For anyone having the same problem, here is the solution.
Solution
I am using the File System API from the react-native-fetch-blob library. This is because I tought it was way better documented and easier to understand than the 'react-native-fs' library.
I request an image from the server, receive a base64 and I then save it to the Pictures directory in the android fs.
I save the image like this:
var RNFetchBlob = require('react-native-fetch-blob').default;
const PictureDir = RNFetchBlob.fs.dirs.PictureDir;
getImageAttachment: function(uri_attachment, filename_attachment, mimetype_attachment) {
return new Promise((RESOLVE, REJECT) => {
// Fetch attachment
RNFetchBlob.fetch('GET', config.apiRoot+'/app/'+uri_attachment)
.then((response) => {
let base64Str = response.data;
let imageLocation = PictureDir+'/'+filename_attachment;
//Save image
fs.writeFile(imageLocation, base64Str, 'base64');
console.log("FILE CREATED!!")
RNFetchBlob.fs.scanFile([ { path : imageLocation, mime : mimetype_attachment } ])
.then(() => {
console.log("scan file success")
})
.catch((err) => {
console.log("scan file error")
})
}).catch((error) => {
// error handling
console.log("Error:", error)
});
},
The following code that is in the above method refreshes the Gallery otherwise the images would not display untill the phone is turned off and back on again.
RNFetchBlob.fs.scanFile([ { path : imageLocation, mime : mimetype_attachment } ])
.then(() => {
console.log("scan file success")
})
.catch((err) => {
console.log("scan file error")
})
Enjoy!
You can absolutely do this with react-native-fs. There's a PicturesDirectoryPath constant which isn't mentioned in the README for the project; if you save a file into there it should appear in the Gallery app. If you want it to appear in your own album, just make a new directory in that folder and save the file into there, eg
const myAlbumPath = RNFS.PicturesDirectoryPath + '/My Album'
RNFS.mkdir(myAlbumPath)
.then(/* write/copy/download your image file into myAlbumPath here */)
I don't have full example code anymore sorry, because I ended storing images in my app's private cache directory instead. Hope this helps anyway!