How does Kong Api Gateway http-log works - linux

As per Kong documentation
**
$ curl -X POST http://kong:8001/apis/{api}/plugins \
--data "name=http-log" \
--data "config.http_endpoint=http://mockbin.org/bin/:id/" \
--data "config.method=POST" \
--data "config.timeout=1000" \
--data "config.keepalive=1000"
**
log will be create at http_endpoint.
I am unable to understand how does kong http-log works.
Suppose my request host is x.x.x.x and kong in installed in my local system,where should i look for log generated after adding http-log plugin.is http-log is accessible using console?

You have to create a listener on the location which is specified as config.http_endpoint. Endpoint has to handle config.method. It will receive a big JSON with all the log info in it.
Check example log JSON at click here
My Suggestion:
Best option here is to set this end point to the elastic search end point to receive all your logs and use Kibana UI on top of elastic to add the visualization to your log data.

HTTP Log -
Send request and response logs to an HTTP server.
the config.http_endpoint is your log server where you can view your logs

Related

Gitlab API Miroring dost not accept address with %20

I am trying to create mirrors on my GitLab via API and I am able to do that just fine. Problem appears when I try to create a mirror to an address that has URL encoded space "%20" in it.
When I call git lab API with following curl:
curl --request POST --data 'url=https://user:password#remotegit.com/Repo%20Mirror%20Test/_git/Repo%20Mirror%20Test' --data "enabled=true" --header "Authorization: Bearer TOKEN" "https://mygit.com/api/v4/projects/171/remote_mirrors"
I get following response:
{"id":171,"enabled":true,"url":null,"update_status":"none","last_update_at":null,"last_update_started_at":null,"last_successful_update_at":null,"last_error":null,"only_protected_branches":false,"keep_divergent_refs":null}
"url":null does not appear when I use any other address without "%20"
When I do this via UI with the same URL it works just fine. I tried to change " for ' to stop any expansion from happening but no luck. In UI I also looked to Developer tools if there is anything different but string is sent in the same format, unchanged.
GitLab server version: 15.2.2
Any ideas what could cause this problem?
All right the whole URL needed to be encoded, you can do that in "https://www.urlencoder.org" or in my case I needed to use it in Bash script so I installed a package "gridsite-clients" which contains "urlencode" which does basically the same thing. Once the address was encoded all worked as expected. So the final request would look like this:
curl --request POST --data 'url=https%3A%2F%2Fuser%3Apassword%40remotegit.com%2FRepo%2520Mirror%2520Test%2F_git%2FRepo%2520Mirror%2520Test' --data "enabled=true" --header "Authorization: Bearer TOKEN" "https://mygit.com/api/v4/projects/171/remote_mirrors"

CURL Rest API via Proxy

I want to get data from ServiceNow via a CURL in Putty via a Proxyserver (Plan is to implement it to a PySpark script later on) and then save the data onto the server.
My Command looks like this:
curl -x <proxyadress:port> -U proxyuser:proxypassword -u '<apiuser:apipassword>' -d status="message" "https:/apiadress" -H 'Accept: application/json'
I get the error message:
{"error":{"message":"Invalid content-type. Supported request media types for this service are: [application/json, application/xml, text/xml]","detail":null},"status":"failure"}
A few days ago I was able to have the data printed into the log but didn't manage to replicate the command ... what's wrong?
Thanks for your help

I receive a 502 Bad Gateway occasionally during the execution of my node.js app on IBM Bluemix

I am running a node.js app on Bluemix which basically is a REST API for read/write operations on a Cloudant (CouchDb) database.
Incoming requests are authenticated by an injected passport-http-bearer strategy middleware into the express framework. My app uses the bearer token to receive information about the user.
This is not very performant at the moment (we are working on a caching mechanism), but in general it works. When I send much requests in parallel (e.g. in function tests), sometimes I receive the 502 Bad Gateway response instead of the expected results, which fails nearly every test suite run. On my local deployment it works without problems.
Maybe you have a scaling issue? When you say many parallel requests - is it possible that the service reply times go beyond that what router expects (120 seconds I think) with many requests?
Can you try to push your app a little harder with Apache Bench maybe?
ab -n 10000 -c 100 -s 120 -H "Authorization: Bearer <token>" https://your-app/
And then in parallel check responses with something like:
#!/bin/bash
BEARER=<your-token>
URL=<your-app>
TIMEFORMAT="TIME: %E"
while true; do R=$(time echo -e REQUEST: $(date)\\nREPLY: $(curl -X GET -s --insecure --header "Accept: application/json" --header "Authorization: Bearer $BEARER" "https://$URL") 2>>trace); echo "$R" >>trace; echo $R|grep -q "502" && echo -e "Found 502 reply\n$R"; done
HP
#Jeff-Sloyer is correct in suggesting retry logic in your push script. Additionally, you should check the status of the runtime and any services being used on the Bluemix status page. For more information on why you may be receiving this error, please see the information noted below:
https://www.ng.bluemix.net/docs/troubleshoot/managingapps.html
I have seen this with unreliable networking. I would use some retry login for your push script to guarantee a deploy.

I want to Transfer some of my data from WHM server to SoftLayer Object Storage without using FTP or SCP, can any one suggest the way out?

I have tried this, but it is just adding the file to the object storage..
$ curl -i -XPUT -H "X-Auth-Token: AUTH_tkb26239d441d6401d9482b004d45f7259" --data-binary "Created for testing REST client" https://dal05.objectstorage.softlayer.net/v1/AUTH_df0de35c-d00a-40aa-b697-2b7f1b9331a6/container2/folder3/file1.txt
The swift client is an easy way to list/upload/download files on SoftLayer Object storage.
https://swiftstack.com/docs/integration/python-swiftclient.html

How to find Windows Azure Image IDs?

How can I find the publicly available Image IDs on Windows Azure?
I found this related question - Azure: List OS Images
But, the answer requires Windows+PowerShell while I need a way to get it on Linux or REST/
Use the URL specified here:
http://msdn.microsoft.com/en-us/library/windowsazure/jj157191.aspx
You'll need to provide a client certificate when sending the request.
If you are using curl on Linux, add the --cert to point to a .pem file (you'll need to upload it to the administrator's management certificate as a .cer file first).
Don't forget to add the x-ms-version header for it to work:
-H "x-ms-version: 2013-03-01"
Here is an example of using curl to get the auto-scale information for a cloud service
curl -H "accept: application/json" -H "x-ms-version: 2013-10-01"
--cert azure-cert.pem $AUTOSCALEURL

Resources