Skip to content

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.

NOTE

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:

json
{
    "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:

yaml
# ...
exporters:
  - kind: webhook
    endpointUrl: https://your-webhook-url.com/
# ...
Field nameMandatoryTypeDefaultDescription
kindYesstringnoneValue should be webhook.
This field is mandatory and describes which retriever you are using.
endpointUrlYesstringnoneEndpointURL of your webhook.
flushIntervalNoint60000The interval in millisecond between 2 calls to the webhook (if the maxEventInMemory is reached before the flushInterval we will call the exporter before).
maxEventInMemoryNoint100000If we hit that limit we will call the exporter.
secretNostringnoneSecret used to sign your request body and fill the X-Hub-Signature-256 header.
See signature section for more details.
metaNomap[string]stringnoneAdd all the information you want to see in your request.
headersNomap[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:

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"},
            },
        },
    },
    // ...
}
client, err := ffclient.New(config)
defer client.Close()
FieldMandatoryDescription
EndpointURL YesEndpointURL of your webhook
Secret NoSecret used to sign your request body and fill the X-Hub-Signature-256 header.
See signature section for more details.
MetaNoAdd all the information you want to see in your request.
HeadersNoList of Headers to send to the endpoint

Released under the MIT License.