Skip to main content
Version: v1.40.0

Webhook

Overview​

Export evaluation data by calling a HTTP Webhook.

Everytime the FlushInterval or MaxEventInMemory is reached an HTTP call will be emitted to the Webhook exporter.

info

If for some reason the Webhook HTTP call fails, we will keep the data in memory and retry to add the next time we reach FlushInterval or MaxEventInMemory.

Webhook format​

If you have configured a webhook, a POST request will be sent to the EndpointURL with a body in this format:

{
"meta": {
"hostname": "server01",
// ...
},
"events": [
{
"kind": "feature",
"contextKind": "anonymousUser",
"userKey": "14613538188334553206",
"creationDate": 1618909178,
"key": "test-flag",
"variation": "Default",
"value": false,
"default": false,
"source": "SERVER"
},
// ...
]
}

Signature​

This header X-Hub-Signature-256 is sent if the webhook is configured with a secret. This is the HMAC hex digest of the request body, and is generated using the SHA-256 hash function and the secret as the HMAC key.

caution

The recommendation is to always use the Secret and on your API/webhook always verify the signature key to be sure that you don't get into a man-in-the-middle attack.

Configure the relay proxy​

To configure your relay proxy to use the Webhook exporter, you need to add the following configuration to your relay proxy configuration file:

goff-proxy.yaml
# ...
exporter:
kind: webhook
endpointUrl: https://your-webhook-url.com/
# ...
Field nameMandatoryTypeDefaultDescription
kindstringnoneValue should be webhook.
This field is mandatory and describes which retriever you are using.
endpointUrlstringnoneEndpointURL of your webhook.
flushIntervalint60000The interval in millisecond between 2 calls to the webhook (if the maxEventInMemory is reached before the flushInterval we will call the exporter before).
maxEventInMemoryint100000If we hit that limit we will call the exporter.
secretstringnoneSecret used to sign your request body and fill the X-Hub-Signature-256 header.
See signature section for more details.
metamap[string]stringnoneAdd all the information you want to see in your request.
headersmap[string][]stringnoneAdd all the headers you want to add while calling the endpoint

Configure the GO Module​

To configure your GO module to use the Webhook exporter, you need to add the following configuration to your ffclient.Config{} object:

example.go
config := ffclient.Config{
// ...
DataExporter: ffclient.DataExporter{
// ...
Exporter: &webhookexporter.Exporter{
EndpointURL: " https://webhook.url/",
Secret: "secret-for-signing",
Meta: map[string]string{
"extraInfo": "info",
},
Headers: map[string][]string{
"Authorization": {"Bearer auth_token"},
},
},
},
// ...
}
err := ffclient.Init(config)
defer ffclient.Close()
FieldMandatoryDescription
EndpointURL EndpointURL of your webhook
Secret Secret used to sign your request body and fill the X-Hub-Signature-256 header.
See signature section for more details.
MetaAdd all the information you want to see in your request.
HeadersList of Headers to send to the endpoint