HTTP Monitor - Process JSON

More
2 years 5 months ago - 2 years 5 months ago #23115 by prashant
HI,
I have a VPS with Static IP let's assume 8.8.8.8 and open port 4300. I had like to receive request on this port and process the JSON to make records in CSV files.  I have provided details to process below. I am highlighting all my mistakes in trying to get this to work

1. Under connections , I setup a TCP/IP and create a new entry called Static , port 4300
2. I create a transformation , called JSONify
    2.1 I don't need validation, deleted that
    2.2  Under transformation , I select Decode JSON array , but not clear what to do
3. I create a Writer : CSV file , define a location for the file 
4. Under Event Monitor , I select Connection - Static, Under transformation Jsonify ,under parameters page to check URL TO Check not clear what to write here?
5. Under Maintain I ensure the services are ON and ticked
6. Under Services Windows , I ensure HTTP monitor is started

I am able to send a CURL POST request on the internet, but 
1. Get no success/fail as a reply back on the request 
2. I have no clues how to decode the JSON below to get a csv friendly output 
3. How to see all the request which have been received when sending the curl request 

For sake of brevity let's assume the JSON below and I wish to process it as below

name,age,id,product,quantity
John,30,123,iPhone,1
John,30,456,MacBook,2



Code:
{     "user": {         "name": "John",         "age": 30     },     "orders": [         {             "id": "123",             "product": "iPhone",             "quantity": 1         },         {             "id": "456",             "product": "MacBook",             "quantity": 2         }     ] }
 
Last edit: 2 years 5 months ago by prashant.

Please Log in or Create an account to join the conversation.

More
2 years 5 months ago #23118 by admin
Replied by admin on topic HTTP Monitor - Process JSON
Thank you I will create an example for you

Mike
ETL Architect

Please Log in or Create an account to join the conversation.

More
2 years 5 months ago #23123 by Peter.Jonson
Good moring.

Based on JSON example you provided I have created a working example.

It transforms all JSON files in the directory into CSV file.
The same approach can be used to transform JSON stored in the blob field

See attached zip file.

File Attachment:

File Name: Case21.zip
File Size:3 KB
 

 

Peter Jonson
ETL Developer

Please Log in or Create an account to join the conversation.

More
2 years 5 months ago #23124 by Peter.Jonson
Regarding HTTP reader

www.etl-tools.com/wiki/advanced-etl-proc...reader-sources/http/

It was originally created to process HTTP forms and it does not support JSON as body at the moment

Regarding HTTP Monitor

www.etl-tools.com/wiki/advanced-etl-proc...nitors/http-monitor/

It is used to start package excution from the third party software.

Imagine that you have a very long running process on lynix
It might take 30 mitues to complete or two hours.
At the end of this process you want to start aetl package excution.
All you need to is to use CURL to access HTTP url and the package execution will start.

When we talk about web hooks there are several things to consder.

1. Webhook must be constatly available, that makes patching servers and rebooting them difficult. So it is better to have two servers and switch between them when necessary
2. Web hook must be very fast, what if you get several thousands calls per second but it takes 30 seconds to create a CSV file?
3. What is theres an error in the transformation and all the hook data must be reprocessed?

So it is better to store hook data in the database and process it when necessary using scheduler
 

Peter Jonson
ETL Developer

Please Log in or Create an account to join the conversation.

More
2 years 5 months ago - 2 years 5 months ago #23140 by prashant
My understanding now is URL Logger is superior for receiving webhooks with JSON data , database provided a fairly advance app from logging perspective.I have already requested it to also do some executions in separate thread. 

HTTP Monitor is beginning to make "some sense" to me. Few questions

1. HTTP Monitor in current status will not send any code back , "failure/success" back to source ? 
2. What does URL to check in parameters page do ? I see example of http://localhost:9000/startpackage.html , but don't understand this

 
Last edit: 2 years 5 months ago by prashant.

Please Log in or Create an account to join the conversation.

More
2 years 5 months ago - 8 months 1 week ago #23142 by prashant
Also some question from your solution
1. Ensure no prefix "user:" simply deletes "user:" key label and grabs the pair name & age and stores in field [UserInfo]
2. Is there a way to preview what "each" step is doing for n00b like me to figure what's happening ? I assume because it's a file object ? I tried a small experiment with below , but cannot see the output 
3. When I try to run this I get an output saying below. I tried removing check box of removing log files , but still error


 
Last edit: 8 months 1 week ago by admin.
The following user(s) said Thank You: Peter.Jonson

Please Log in or Create an account to join the conversation.

Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Read more
Marketing
Set of techniques which have for object the commercial strategy and in particular the market study.
Google
Accept
Decline
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Google Analytics
Accept
Decline
Functional
Tools used to give you more features when navigating on the website, this can include social sharing.
Advertisement
If you accept, the ads on the page will be adapted to your preferences.
Google Ad
Accept
Decline
Save