Skip to content

Instantly share code, notes, and snippets.

@takurx
Last active June 2, 2024 22:56
Show Gist options
  • Save takurx/37af3cad0a6d40d3412d4670d9c56828 to your computer and use it in GitHub Desktop.
Save takurx/37af3cad0a6d40d3412d4670d9c56828 to your computer and use it in GitHub Desktop.
try to log kong and fiware

log_of_kong_api_gateway-6

fiware command

curl -X GET \
    http://localhost:1026/v2/entities \
    -H 'fiware-service: atosioe' \
    -H 'fiware-servicepath: /lorattn'

fieware command, version

curl -X GET \
    http://localhost:4061/version \
    -H 'fiware-service: atosioe' \
    -H 'fiware-servicepath: /lorattn'

fiware command, version, responce

chino@chino-Legion-5-15IAH7H:~$ curl -X GET \
    http://localhost:4061/version \
    -H 'fiware-service: atosioe' \
    -H 'fiware-servicepath: /lorattn'
{"libVersion":"2.21.0","port":4041,"baseRoot":"/","version":"1.2.5"}

fieware command, version, -1

curl -X GET http://localhost:4061/version

fieware command, version, responce -1

chino@chino-Legion-5-15IAH7H:~$ curl -X GET http://localhost:4061/version
{"libVersion":"2.21.0","port":4041,"baseRoot":"/","version":"1.2.5"}

boot on aws

  • ubuntu 24.04
  • t2.micro, vCPU 1, 8GB
git clone https://github.com/Atos-Research-and-Innovation/IoTagent-LoRaWAN.git

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

cd IoTagent-LoRaWAN
sudo docker compose -f examples/stm32_ttn_tutorial/docker-compose.yml up

boot on aws and command responce

chino@chino-Legion-5-15IAH7H:~$ curl -X GET http://54.238.24.118:4061/version
{"libVersion":"2.21.0","port":4041,"baseRoot":"/","version":"1.2.5"}

kong boot fail -1

chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822$ curl -Ls https://get.konghq.com/quickstart | bash

mv: cannot move '/tmp/kong/quickstart/environment' to '/tmp/tmp.pQWOUc5iXc/environment': Permission denied
• Deploying Kong Gateway to Docker...
ℹ Debugging info logged to:
    /tmp/kong/quickstart/kong-quickstart.log
✘ Docker is not available, check /tmp/kong/quickstart/kong-quickstart.log

kong boot fail -2

chino@chino-Legion-5-15IAH7H:~$ sudo curl -Ls https://get.konghq.com/quickstart | bash
[sudo] password for chino: 

• Deploying Kong Gateway to Docker...
ℹ Debugging info logged to:
    /tmp/kong/quickstart/kong-quickstart.log
✘ Docker is not available, check /tmp/kong/quickstart/kong-quickstart.log

kong boot success

chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822$ sudo curl -Ls https://get.konghq.com/quickstart | sudo bash

• Deploying Kong Gateway to Docker...
ℹ Debugging info logged to:
......
......
=======================================================
 ⚒️                              Administer Kong Gateway
=======================================================

• Kong Gateway Admin API endpoint:
   HTTP = http://localhost:8001

• To administer the gateway with curl:

→ curl -s https://localhost:8001

• To stop the gateway run:

→ curl -s https://get.konghq.com/quickstart | \ 
    bash -s -- -d -a kong-quickstart

Or remove the Docker container directly.

kong, set up, service, route

curl -i -s -X POST http://localhost:8001/services \
  --data name=example_service \
  --data url='http://httpbin.org'

 curl -X GET http://localhost:8001/services/example_service

curl --request PATCH \
  --url localhost:8001/services/example_service \
  --data retries=6

curl -i -X POST http://localhost:8001/services/example_service/routes \
   --data 'paths[]=/mock' \
   --data name=example_route

curl -X GET http://localhost:8001/services/example_service/routes/example_route
curl -i -s -X POST http://localhost:8001/services \
 --data name=example_service \
 --data url='http://httpbin.org'

kong, set up -1

curl -i -s -X POST http://localhost:8001/services \
 --data name=service_fiware_1 \
 --data url='http://localhost:4061'
curl -i -X POST http://localhost:8001/services/service_fiware_1/routes \
 --data 'paths[]=/route_fiware' \
 --data name=route_fiware_1
curl -X GET http://localhost:8000/route_fiware/version

kong, set up -1, responce, -1

chino@chino-Legion-5-15IAH7H:~$ curl -i -s -X POST http://localhost:8001/services \
>  --data name=example_fiware_1 \
>  --data url='http://localhost:4061/version'
HTTP/1.1 201 Created
Date: Sun, 02 Jun 2024 22:05:43 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 1f7ceb41ebe7de0f41978e6bd723f371
Content-Length: 383
X-Kong-Admin-Latency: 24
Server: kong/3.7.0.0-enterprise-edition

{"protocol":"http","updated_at":1717365943,"port":4061,"client_certificate":null,"host":"localhost","connect_timeout":60000,"tags":null,"read_timeout":60000,"path":"/version","name":"example_fiware_1","ca_certificates":null,"id":"81cba50c-e492-474d-830f-6d62fc9fcc56","write_timeout":60000,"enabled":true,"retries":5,"created_at":1717365943,"tls_verify":null,"tls_verify_depth":null}chino@chino-Legion-5-15IAH7H:~$ 
chino@chino-Legion-5-15IAH7H:~$ curl -i -X POST http://localhost:8001/services/example_fiware_1/routes \
>  --data 'paths[]=/mock_fiware' \
>  --data name=example_fiware_1
HTTP/1.1 201 Created
Date: Sun, 02 Jun 2024 22:06:07 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 949ee0526fd432274aa41a6ae3593848
Content-Length: 495
X-Kong-Admin-Latency: 23
Server: kong/3.7.0.0-enterprise-edition

{"methods":null,"protocols":["http","https"],"preserve_host":false,"hosts":null,"regex_priority":0,"snis":null,"tags":null,"paths":["/mock_fiware"],"request_buffering":true,"created_at":1717365967,"path_handling":"v0","updated_at":1717365967,"service":{"id":"81cba50c-e492-474d-830f-6d62fc9fcc56"},"https_redirect_status_code":426,"sources":null,"id":"0861b420-2bae-41e4-935a-30b09b577de3","strip_path":true,"headers":null,"destinations":null,"name":"example_fiware_1","response_buffering":true}chino@chino-Legion-5-15IAH7H:~$ 
chino@chino-Legion-5-15IAH7H:~$ 

kong, set up -1, responce, -2

chino@chino-Legion-5-15IAH7H:~$ curl -i -s -X POST http://localhost:8001/services \
>  --data name=service_fiware_1 \
>  --data url='http://localhost:4061/version'
HTTP/1.1 409 Conflict
Date: Sun, 02 Jun 2024 22:26:45 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 2dac8a2c04648c429498ae186e31d50c
Content-Length: 155
X-Kong-Admin-Latency: 9
Server: kong/3.7.0.0-enterprise-edition

{"code":5,"message":"UNIQUE violation detected on '{name=\"service_fiware_1\"}'","name":"unique constraint violation","fields":{"name":"service_fiware_1"}}chino@chino-Legion-5-15IAH7H:~$ 
chino@chino-Legion-5-15IAH7H:~$ curl -i -X POST http://localhost:8001/services/service_fiware_1/routes \
>  --data 'paths[]=/route_fiware' \
>  --data name=route_fiware_1
HTTP/1.1 201 Created
Date: Sun, 02 Jun 2024 22:27:04 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 9635d9157c68fd74ab6c3c16d063b377
Content-Length: 494
X-Kong-Admin-Latency: 23
Server: kong/3.7.0.0-enterprise-edition

{"methods":null,"protocols":["http","https"],"preserve_host":false,"hosts":null,"regex_priority":0,"snis":null,"tags":null,"paths":["/route_fiware"],"request_buffering":true,"created_at":1717367224,"path_handling":"v0","updated_at":1717367224,"service":{"id":"ddda0236-a3f5-4b20-ab3c-1aa75848bb1b"},"https_redirect_status_code":426,"sources":null,"id":"191758fd-0671-4c2e-9241-01f86997aa87","strip_path":true,"headers":null,"destinations":null,"name":"route_fiware_1","response_buffering":true}chino@chino-Legion-5-15IAH7H:~$ 
chino@chino-Legion-5-15IAH7H:~$ curl -X GET http://localhost:8000/route_fiware
{
  "message":"An invalid response was received from the upstream server",
  "request_id":"63c67376264ed8425726d51ffabf1b5d"
}

kons, set up -2

curl -i -s -X POST http://localhost:8001/services \
 --data name=example_fiware_2 \
 --data url='http://54.238.24.118:4061/version'

kong, set up -3, try to httpbin

curl -i -s -X POST http://localhost:8001/services \
  --data name=example_service \
  --data url='http://httpbin.org'

curl -i -X POST http://localhost:8001/services/example_service/routes \
   --data 'paths[]=/mock' \
   --data name=example_route
curl -X GET http://httpbin.org

curl -X GET http://localhost:8000/mock 

kong, set up -3, try to httpbin, responce

chino@chino-Legion-5-15IAH7H:~$ curl -i -s -X POST http://localhost:8001/services \
>   --data name=example_service \
>   --data url='http://httpbin.org'
HTTP/1.1 201 Created
Date: Sun, 02 Jun 2024 22:22:18 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 85dae45d91bb65087511dd6196941c7c
Content-Length: 376
X-Kong-Admin-Latency: 12
Server: kong/3.7.0.0-enterprise-edition

{"protocol":"http","updated_at":1717366938,"port":80,"client_certificate":null,"host":"httpbin.org","connect_timeout":60000,"tags":null,"read_timeout":60000,"path":null,"name":"example_service","ca_certificates":null,"id":"a237f228-3030-4c10-bdf3-735d936536a6","write_timeout":60000,"enabled":true,"retries":5,"created_at":1717366938,"tls_verify":null,"tls_verify_depth":null}chino@chino-Legion-5-15IAH7H:~$ 
chino@chino-Legion-5-15IAH7H:~$ curl -i -X POST http://localhost:8001/services/example_service/routes \
>    --data 'paths[]=/mock' \
>    --data name=example_route
HTTP/1.1 201 Created
Date: Sun, 02 Jun 2024 22:22:28 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 65e3805d14bfd723e9a7f8727051c010
Content-Length: 485
X-Kong-Admin-Latency: 20
Server: kong/3.7.0.0-enterprise-edition

{"methods":null,"protocols":["http","https"],"preserve_host":false,"hosts":null,"regex_priority":0,"snis":null,"tags":null,"paths":["/mock"],"request_buffering":true,"created_at":1717366948,"path_handling":"v0","updated_at":1717366948,"service":{"id":"a237f228-3030-4c10-bdf3-735d936536a6"},"https_redirect_status_code":426,"sources":null,"id":"b9c7393f-0832-4c50-a736-34ca348203f5","strip_path":true,"headers":null,"destinations":null,"name":"example_route","response_buffering":true}chino@chino-Legion-5-15IAH7H:~$ curl -X GET http://localhost:8000/mock 
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>httpbin.org</title>
......
......
</body>

</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment