Giter VIP home page Giter VIP logo

apisix-logger's Introduction

apisix-logger

  1. Clone APISIX docker
git clone https://github.com/apache/apisix-docker
  1. Add plugin to config.yaml

Go to /example/apisix_conf/config.yaml and add the following lines to the file:

plugins:                           # plugin list (sorted by priority)
  - proxy-rewrite                  # priority: 1008
  - http-logger                    # priority: 410
  1. Start APISIX docker

Go to /example

docker compose up -d
  1. Check if the plugin is loaded
curl --location --request GET 'http://127.0.0.1:9180/apisix/admin/plugins/list'
  1. Start the logger

Go to /logger in this repo

docker compose up -d
  1. Add a route
curl --location --request PUT 'http://127.0.0.1:9180/apisix/admin/routes' \
--header 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' \
--header 'Content-Type: application/json' \
--data '{
  "id": "test",
  "uri": "/test",
  "methods": ["POST"],  
  "upstream": {
    "type": "roundrobin",
    "nodes": {
      "host.docker.internal:3000": 1
    }
  },
    "plugins": {  
        "proxy-rewrite": {  
            "regex_uri": ["^/chat(.*)", "/api/v1/process/7a0cd6ca-454c-4cf2-b6c3-daf712eded50$1"]  
        },
        "http-logger": {
            "uri": "http://host.docker.internal:8080/logs",
            "include_req_body": true,
            "include_resp_body": true
        },
        "total_tokens_counter": {}
    }  
}'
  1. Test the route
curl --location 'http://localhost:9080/chat' \
--header 'x-api-key: sk-SWkSvU6jTkOXzA5filIbYy0Qk7IsbJhc2jFbFRsGSPI' \
--header 'Content-Type: application/json' \
--data '{"inputs": {"input":"Hi"}}'
  1. Check the logs
docker logs apisix-logger_logger_1

apisix-logger's People

Contributors

warching avatar somethingwentwell avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.