Skip to main content
Version: 1.0.x

Flow Configuration Template

Flow Configuration

/etc/lunar-proxy/flows/flow.yaml
name: <FlowName> # The name of the flow, e.g., ClientSideLimitingFlow

filter:
url: <URLPattern> # Define the URL pattern for the filter, e.g., api.example.com/*
method:
- <HTTPMethod> # Optional: List of HTTP methods, e.g., GET, POST
headers:
- key: <HeaderKey> # Optional: Header key, e.g., 'X-API-Key'
value: <HeaderValue> # Optional: header value, e.g., '12345', '67890'

processors:
Limiter:
processor: Limiter # Limiter processor for rate limiting
parameters:
- key: quota_id
value: <QuotaID> # Specify the quota ID, e.g., MyQuota

GenerateResponse:
processor: GenerateResponse # Generate a response when a limit is exceeded
parameters:
- key: status
value: 429 # HTTP status code for quota exceeded, e.g., 429 (Too Many Requests)
- key: body
value: "Quota Exceeded. Please try again later." # Response body text
- key: Content-Type
value: text/plain # Content type for the response

flow:
request:
- from:
stream:
name: globalStream # The stream to start the request flow
at: start # Start point
to:
processor:
name: Limiter # Process the request through the Limiter processor

- from:
processor:
name: Limiter # After the Limiter processor
condition: above_limit # If the request is blocked due to quota exceeded
to:
processor:
name: GenerateResponse # Generate the 429 response

- from:
processor:
name: Limiter # After the Limiter processor
condition: below_limit # If the request is allowed (below quota limit)
to:
stream:
name: globalStream # Send the request to the global stream
at: end # End point of the request flow

response:
- from:
processor:
name: GenerateResponse # In case of quota exceeded, send the response
to:
stream:
name: globalStream # Send response back to the global stream
at: end # End point of the response flow
ParameterDescriptionTypeMandatory/OptionalExample
nameThe name of the flow, describing its purpose or function.StringMandatoryClientSideLimitingFlow
filter.urlURL pattern to match requests for this flow.StringMandatoryapi.website.com/*
filter.methodList of HTTP methods (GET, POST, etc.) that the flow applies to.ListOptional['GET', 'POST']
filter.headers.keyHeader key for filtering requests. Used to apply limits based on specific headers.StringOptionalX-API-Key
filter.headers.valueheader value to match the header key.ListOptional'67890'
processors.Limiter.processorThe processor that handles rate-limiting.StringMandatoryLimiter
processors.Limiter.parameters.keyKey to specify the parameter for the limiter processor.StringMandatoryquota_id
processors.Limiter.parameters.valueValue of the quota used by the limiter.StringMandatoryMyQuota
processors.GenerateResponse.processorProcessor that generates the response when the limit is exceeded.StringMandatoryGenerateResponse
processors.GenerateResponse.parameters.keyKey to specify the response parameter (e.g., status, body, content type).StringMandatorystatus, body, Content-Type
processors.GenerateResponse.parameters.valueValues corresponding to the keys (status code, response message, content type).VariesMandatory429, Quota Exceeded..., text/plain
flow.request.from.stream.nameName of the stream used at the start of the request flow.StringMandatoryglobalStream
flow.request.from.stream.atThe point in the stream where the flow starts.StringMandatorystart
flow.request.to.processor.nameName of the processor to route the request to.StringMandatoryLimiter, GenerateResponse
flow.request.to.processor.conditionCondition to determine whether the request is blocked or allowed (quota exceeded or not).StringOptionalabove_limit, below_limit
flow.response.from.processor.nameName of the processor for generating the response in case of quota exceeded.StringMandatoryGenerateResponse
flow.response.to.stream.nameName of the stream to send the response to.StringMandatoryglobalStream
flow.response.from.stream.atThe point in the stream where the response starts.StringMandatorystart

Quota Configuration

Please refer to the Configure your API Quotas Page.