How can I connect my Power BI Service Dataset to Elasticsearch through Logstash? I need config file for this problem.? - logstash

I tried this config file but it is throwing an error.
it is my config file which i try:
input {
http {
http_method => "post"
url => "https://api.powerbi.com/v1.0/myorg/datasets/your-dataset-id/"
headers => {
"Content-Type" => "application/json"
"Authorization" => "Bearer access_tocken"
}
}
}
output {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "powerbi"
}
}

Related

GET http://localhost:3000/user/authenticated 401 (Unauthorized) how to bypass this error for certain requests

GET http://localhost:3000/user/authenticated 401 (Unauthorized) how to bypass this error for certain requests that the user does not need to be authenticated. For example an eCommerce store has the ability to display all the products to any visitor to that website however a seller would need to login. So how I bypass this with code I have created below? Sorry if this is poorly explained I new to backend and user authentication.
Please note I have no issue in getting the data, the process works fine. Its just the error appears and I want to remove it.
Below is how I have set up user authentication the error stems from the iaAuthenticated section I will highlight where.
export default {
login : user => {
return fetch('/user/login', {
method : "post",
body : JSON.stringify(user),
headers: {
'Content-Type' : 'application/json'
}
}).then(res=>{
if(res.status !== 401)
return res.json().then(data => data);
else
return {isAuthenticated : false, user: {username : ""}}
})
},
register : user => {
return fetch('/user/register', {
method : "post",
body : JSON.stringify(user),
headers: {
'Content-Type' : 'application/json'
}
}).then(res => res.json())
.then(data => data);
},
logout : ()=> {
return fetch('/user/logout')
.then(res => res.json())
.then(data => data);
},
isAuthenticated : () => {
(error appears from this line)return fetch ('/user/authenticated')
.then(res=>{
if(res.status !== 401)
return res.json().then(data => data);
else
return {isAuthenticated : false, user: {username : ""}}
})
}
}
There's two things that can be done.
Move the file from the dir to a different dir above.
If this makes the page work then the file was the problem
Try seeing any configuration changes you madfe to your apache2.conf or .conf or .htaccess.
If you changes the settings and this works you can try again to see if your file will work.

Logstash configuration basic auth filter not parsed

Hello i followed some guides on how to do basic auth in logstash. However, when i check the outgoing packet from logstash, the HTTP protocol contains "Authorization: Basic %{password}" instead of "Authorization: Basic <base64 encoded string (user:pass)>"
Also, i want to note that i followed this thread
Here is a image of the HTTP packet
here is my config
input {
beats {
host => "localhost"
port => 5044
}
}
filter {
mutate {
remove_field => [ "host", "#timestamp", "#version", "tags", "input", "ecs", "agent", "log", "offset"]
}
grok {
patterns_dir => ["C:\\logstash\\patterns"]
match => { "message" => "%{COMMON_TIMESTAMP:timestamp}"}
}
ruby {
code => "
require 'base64';
event['password'] = Base64.encode64('root:root').sub(/\n/,'')
"
}
}
output {
stdout { codec => rubydebug }
http {
headers => {"Authorization" => "Basic %{password}"}
url => ["http://localhost:9999/api/v1/logs/data"]
http_method => "post"
content_type => "application/json"
format => json
}
}
Is there something i missed? plugin maybe?
Additionally i am using logstash-7.7.0
The thread you followed is old and a lot has changed since it was posted, now you need to use event.set to create a new field according to the documentation.
When you run your current ruby code it will give you an error in the logs.
Something like this:
[2021-03-26T10:36:44,090][ERROR][logstash.filters.ruby ][main][3baa937b943ad54239f24db1ed6452cc66a0a3a60153d0a4dca57bf209157627] Ruby exception occurred: undefined method `[]=' for #<LogStash::Event:0x25a508e2>
You should use this code:
ruby {
code => "
require 'base64'
event.set('password', Base64.encode64('root:root').sub(/\n/,''))
"
}
This will create the password field in your event.
"password" => "cm9vdDpyb290"
update:
To use this password on the headers of the http output filter, you need to create a field with the content of the header first.
mutate {
add_field => { "myHeader" => "Basic %{password}" }
}
Then you need to set the header according to the documentation
headers => ["Authorization", "%{myHeader}"]

PHP curl to nodejs

I have some php code that runs curl commands. However the company I work for is switching over to nodejs and I am not sure how to replicate the request in the same way in node. Or I would even be happy if I could replicate the request on the front end using axios. I don't really care how I do i I just need to replicate the request in the exact same way.
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_HTTPHEADER => array(
'Authorization: Token '.$token
),
CURLOPT_URL => 'https://myWebsite.com/api/led/contents/',
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
url => '#bannerStockUpload/'.$assetName.'/'.$assetName.'_'.$dimensions[1].'.mp4',
thumbnail => '#bannerStockUpload/'.$assetName.'/'.$assetName.'_thumb.jpg',
type => 'video',
width => $dimensions[0],
height => $dimensions[1],
duration => $dur,
name => $assetName."_".$dimensions[0]."x".$dimensions[1]."mp4"
)
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
you can install axios via npm then:
const axios = require('axios');
const data = {
url: '#bannerStockUpload/'.$assetName.'/'.$assetName.'_'.$dimensions[1].'.mp4', // chnage $assetName to js variable
thumbnail: '#bannerStockUpload/'.$assetName.'/'.$assetName.'_thumb.jpg',
type: 'video',
width: $dimensions[0], // change dimension to js variable
height: $dimensions[1], // change dimension to js variable
duration: $dur,
name: $assetName."_".$dimensions[0]."x".$dimensions[1]."mp4"
}
const headers = {
headers: {
Authorization: 'Token ' + $token // add javascript token
}
}
// Make a request for a user with a given ID
axios.post('https://myWebsite.com/api/led/contents/', data, headers)
.then(function (response) {
// handle success
console.log(response);
})
.catch(function (error) {
// handle error
console.log(error);
})

MS Teams Calling - Cannot read .wav file

When a call has been established, attempting to play a prompt using any .wav file results in the following error 500:
"message": "Did not get valid FileSource from downloaded file content"
Tried a few different .wav's:
https://myaudio.blob.core.windows.net/prompts/couchplayin.wav
https://www.pacdv.com/sounds/interface_sound_effects/sound107.wav
Code:
`var url = 'https://graph.microsoft.com/beta/app/calls/' + callID +
"/playPrompt";
axios.post(url,
{
"clientContext": "d45324c1-fcb5-430a-902c-f20af696537c",
"prompts": [
{
"#odata.type": "#microsoft.graph.mediaPrompt",
"mediaInfo": {
"uri": "https://myaudio.blob.core.windows.net/prompts/couchplayin.wav",
"resourceId": "1D6DE2D4-CD51-4309-8DAA-70768651088E"
},
"loop": 5
}
]
},
{
headers: { Authorization: 'Bearer ' + token }
}).then(response => {
console.log(response)
})
.catch(error => {
console.log(error.response)
});`
For anyone experiencing the same issue, I setup a custom WAV file in itunes and converted it using the following parameters and it was successful.
16-bits per sample
16000 sampling rate
mono/single channel.

Got undefined when I try to reach data from node API

I tried to use fetch() method into componentDidMount() method in my react App.
It works on Postman and I got data from URL.
Here is the code in react App :
class WorldMap extends Component {
constructor(){
super()
this.state = {
zoom: 1,
color: "#39464E",
test: ''
}
}
componentDidMount() {
setTimeout(() => {
ReactTooltip.rebuild()
}, 100)
//get all countries in db
fetch('http://localhost:3000/country/20', {
method: 'GET',
headers: {
'Accept' : 'application/json',
'Content-Type' : 'application/json',
},
})
.then(data => {
this.setState({test: data.name_fr})
})
}
countryClick(geography){
console.log(test)
}
}
Here is what i got in Postman when I try to retrieve data :
The problem is that I have undefined in console when I click on country.
From your json structure in postman, looks like you need to access data.name_fr of the response. Also fetch defaults to get and you don't need those extra headers. Your fetch code can be simplified to:
fetch('http://localhost:3000/country/20')
.then(res => res.json())
.then(body => console.log(body.data.name_fr))
You have the wrong data access. In your then, data will be the entire resulting object, with data, error, and message properties. If you logged the data object entirely before you assigned it to your state, you'd probably have noticed that your assumptions were wrong on what was passed to you. Next time, I suggest debugging with the devtools with breakpoints and/or setting logs to trace where the issue is.
.then(data => {
this.setState({test: data.name_fr})
})
should be
.then(results => {
this.setState({test: results.data.name_fr})
})
Change your fetch to this :
fetch('http://localhost:3000/country/20', {
method: 'GET',
headers: {
'Accept' : 'application/json',
'Content-Type' : 'application/json',
},
})
.then(data => data.json())
.then(jsonData =>
this.setState({test:jsonData.name_fr})
)

Resources