Registering events in Drip via REST API with logstash


(Pedro Vivancos) #1

Hi,

I'd like to register some events of an client-server app in Drip (https://www.drip.com) by using Drip REST API but I've failed doing so.

My app generates JSON log such as:

{
"logdate": "2018-07-16 10:57:49.2574",
"user": "myemail@xxxx.com",
"session": "S8B6DmtTf90YvTcOI8d2pEADNzXAkKiP",
"action": "PROCESSED_SESSION",
"params": {
"sessionInit": "2018-07-16 08:57:39.3975",
"sessionEnd": "2018-07-16 10:57:49.2574",
"sessionDuration": 7209.8598999999995
}
}

and I'd like to register that event (session) in Drip like I can do with that cURL command:

curl -X POST "https://api.getdrip.com/v2/MYACCOUNTID/events"
-H 'User-Agent: MyApp'
-H 'Content-Type: application/json'
-u MY_USER_ID:
-d @- << EOF
{
"events": [{
"email": "myemail@xxxx.com",
"action": "New Session"
}]
}
EOF

To do so, I wrote the following logstash config file:

input {
file {
path => ["C:/mypath/*.log"]
codec => json { }
}
}

filter {
if [action] != "PROCESSED_SESSION" {
drop { }
}
}

output {
http {
url => "https://api.getdrip.com/v2/MYACCOUNTID/events"
http_method => "post"
format => "json"
headers => [
'Authorization', 'Basic MY_USER_ID',
'User-Agent', 'myapp',
]
message => "{ 'events': [{ 'email': '%{user}', 'action': 'New Session'}] }"
}
}

But it doesn't work.

Can you give me some clues about how to solve it?

Thanks all in advance


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.