LIGHT

  • News
  • Docs
  • Community
  • Reddit
  • GitHub
Star

Proxy Metrics

The following tutorial will enable the metrics handler on light-proxy.

Backend API

Let’s start the backend API first by following the OpenAPI Backend. We only need to start the first instance with port 8081 for this tutorial as load balancing is not a concern for this tutorial.

InfluxDB

Before starting the proxy server, we need to have a local InfluxDB instance. Let’s start the InfluxDB with Docker by following the Petstore Metrics tutorial.

Light Proxy

Let’s put the light-proxy configuration files into the light-config-test/light-proxy/proxy-metrics folder. You can check out the light-config-test to your workspace like ~/networknt.

Config

First, we copy the config files from the openapi-proxy in the same parent folder to the proxy-metrics folder.

Since we are only using one backend instance, so we need to update the proxy.yml file to leave only one instance for the target server.

proxy.yml

# Target URIs
hosts: https://localhost:8081
Start

Follow the OpenAPI Proxy tutorial to start the light-proxy with config files in the proxy-metrics folder.

cd ~/networknt/light-proxy
mvn clean install -DskipTests
java -Dlight-4j-config-dir=/home/steve/networknt/light-config-test/light-proxy/proxy-metrics -jar target/light-proxy.jar
Test

Test the proxy and backend with the following command.

curl -k https://localhost:8080/v1/getData
curl -k -H "Authorization: Bearer eyJraWQiOiIxMDAiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJ1cm46Y29tOm5ldHdvcmtudDpvYXV0aDI6djEiLCJhdWQiOiJ1cm46Y29tLm5ldHdvcmtudCIsImV4cCI6MTkyMTEwMTY4MCwianRpIjoiX1A5Qk05Sm5TS3I1WWM2ajZHcUw3ZyIsImlhdCI6MTYwNTc0MTY4MCwibmJmIjoxNjA1NzQxNTYwLCJ2ZXJzaW9uIjoiMS4wIiwiY2xpZW50X2lkIjoiZjdkNDIzNDgtYzY0Ny00ZWZiLWE1MmQtNGM1Nzg3NDIxZTczIiwic2NwIjpbInByb3h5LnIiLCJwcm94eS53Il19.Oi1NEF4AVvgyVoVg4mqCVabT-ywdgNE_vlgRob6xmME3C9TXs7r7yWumWpyfQ2fMUfAS9pe3xvVff9mcFN6PMmhZrxVSIlzme9r-lxAsFgMSBjzPfUTZtxHpMb26WpD70zLAqW0dUhLV_k_tBUfnLnzcmqoh446koLDA7z6_cAhruA-nBg794lY1PZbb5Nz1b-WqfFoORnkYuYnYyUpl0loTrLWj_E6svE1QNf-aorJzSeptAAQ0W7SumXTeycNDnfFBc_qQmILmnjG5ayZrhEyFQnVqCdqzqmjBiu6sewgcjmmItdiuIgM1cJXshhPWrSUWpDbjNxCVNysQ5lQREw" https://localhost:8080/v1/getData

Result

{"enableHttp2":true,"httpPort":8080,"enableHttps":true,"value":"value1","httpsPort":8081,"key":"key1"}
Metrics

Let’s add a values.yml to the config folder in the light-config-test/light-proxy/proxy-metrics folder.

values.yml

metrics.enabled: true

We need to enable metrics handler in the handler.yml file and wire it into the request/response chain.

handlers:
  # Light-framework cross-cutting concerns implemented in the microservice
  - [email protected]
  - [email protected]


chains:
  default:
    - exception
    - metrics
    - traceability
    - correlation
    # - cors
    - header
    # - path
    - specification
    - security
    #- body
    #- audit
    #- sanitizer
    - validator
    - proxy

Restart the light-proxy server again and send the test request.

Chronograf

After sending several requests, to go the site http://localhost:8888 and check the tables.

proxy-metrics

  • About Light
    • Overview
    • Testimonials
    • What is Light
    • Features
    • Principles
    • Benefits
    • Roadmap
    • Community
    • Articles
    • Videos
    • License
    • Why Light Platform
  • Getting Started
    • Get Started Overview
    • Environment
    • Light Codegen Tool
    • Light Rest 4j
    • Light Tram 4j
    • Light Graphql 4j
    • Light Hybrid 4j
    • Light Eventuate 4j
    • Light Oauth2
    • Light Portal Service
    • Light Proxy Server
    • Light Router Server
    • Light Config Server
    • Light Saga 4j
    • Light Session 4j
    • Webserver
    • Websocket
    • Spring Boot Servlet
  • Architecture
    • Architecture Overview
    • API Category
    • API Gateway
    • Architecture Patterns
    • CQRS
    • Eco System
    • Event Sourcing
    • Fail Fast vs Fail Slow
    • Integration Patterns
    • JavaEE declining
    • Key Distribution
    • Microservices Architecture
    • Microservices Monitoring
    • Microservices Security
    • Microservices Traceability
    • Modular Monolith
    • Platform Ecosystem
    • Plugin Architecture
    • Scalability and Performance
    • Serverless
    • Service Collaboration
    • Service Mesh
    • SOA
    • Spring is bloated
    • Stages of API Adoption
    • Transaction Management
    • Microservices Cross-cutting Concerns Options
    • Service Mesh Plus
    • Service Discovery
  • Design
    • Design Overview
    • Design First vs Code First
    • Desgin Pattern
    • Service Evolution
    • Consumer Contract and Consumer Driven Contract
    • Handling Partial Failure
    • Idempotency
    • Server Life Cycle
    • Environment Segregation
    • Database
    • Decomposition Patterns
    • Http2
    • Test Driven
    • Multi-Tenancy
    • Why check token expiration
    • WebServices to Microservices
  • Cross-Cutting Concerns
    • Concerns Overview
  • API Styles
    • Light-4j for absolute performance
    • Style Overview
    • Distributed session on IMDG
    • Hybrid Serverless Modularized Monolithic
    • Kafka - Event Sourcing and CQRS
    • REST - Representational state transfer
    • Web Server with Light
    • Websocket with Light
    • Spring Boot Integration
    • Single Page Application
    • GraphQL - A query language for your API
    • Light IBM MQ
    • Light AWS Lambda
    • Chaos Monkey
  • Infrastructure Services
    • Service Overview
    • Light Proxy
    • Light Mesh
    • Light Router
    • Light Portal
    • Messaging Infrastructure
    • Centralized Logging
    • COVID-19
    • Light OAuth2
    • Metrics and Alerts
    • Config Server
    • Tokenization
    • Light Controller
  • Tool Chain
    • Tool Chain Overview
  • Utility Library
  • Service Consumer
    • Service Consumer
  • Development
    • Development Overview
  • Deployment
    • Deployment Overview
    • Frontend Backend
    • Linux Service
    • Windows Service
    • Install Eventuate on Windows
    • Secure API
    • Client vs light-router
    • Memory Limit
    • Deploy to Kubernetes
  • Benchmark
    • Benchmark Overview
  • Tutorial
    • Tutorial Overview
  • Troubleshooting
    • Troubleshoot
  • FAQ
    • FAQ Overview
  • Milestones
  • Contribute
    • Contribute to Light
    • Development
    • Documentation
    • Example
    • Tutorial
“Proxy Metrics” was last updated: November 18, 2020: fixes #210 add a tutorial to enable metrics handler on the light-proxy server (e2e318b)
Improve this page
  • News
  • Docs
  • Community
  • Reddit
  • GitHub
  • About Light
  • Getting Started
  • Architecture
  • Design
  • Cross-Cutting Concerns
  • API Styles
  • Infrastructure Services
  • Tool Chain
  • Utility Library
  • Service Consumer
  • Development
  • Deployment
  • Benchmark
  • Tutorial
  • Troubleshooting
  • FAQ
  • Milestones
  • Contribute