Set Sidecar Filters

This guide will help you enable and disable Grey Matter Sidecar filters.

Learn how to configure the Grey Matter Sidecar in Fabric to achieve the following:

  • Dynamic configuration for adaptive proxying

  • Service discovery through the Grey Matter Control API

  • Hot reloading of configuration through the Grey Matter Control API

Prerequisites

Successful installation of the following:

  • Grey Matter

  • Grey Matter Proxy

  • Grey Matter Control API

Step 1: Edit the Sidecar Proxy

To enable filters, you'll need to edit the proxy you've created. The following command will bring up the proxy in your favorite console editor in your shell.

greymatter edit proxy proxy-example

Note the two fields: active_proxy_filters and proxy_filters.

Add Another List Item

In the active_proxy_filters array, add another list item.

  "active_proxy_filters": [
    "gm.metrics",
    "gm.observables"
  ],

Step 2: Configure the Observables Filter

So far you've only told Grey Matter Sidecar which filters you want to run, but you have not provided configuration for the observables filter.

gm_observables

To configure the observables filter, look under the proxy_filters object.

    "gm_observables": {
      "emitFullResponse": false,
      "useKafka": false,
      "topic": "proxy-example",
      "eventTopic": "proxy-example-topic",
      "kafkaZKDiscover": false,
      "kafkaServerConnection": ""
    }

Note: the gm_observables object. That is where you will configure your new filter.

If needed, enable Kafka as a message buffer by specifyinguseKafka, eventTopic, and kafkaServerConnection.

Learn more about the Grey Matter Observables Filter.

Save Your Configuration

Once you've edited the configuration to your liking, save the newly modified JSON. The Grey Matter CLI will update your instance of Grey Matter Control API.

Now that you've saved your configuration, proxies with the key proxy-example will receive their new configuration and hot reload with the new filter enabled.

Step 3: Test

To see your new filter in action, tail the logs of the example proxy container with the following command:

docker logs -f gmfabric_example-proxy_1

Successful Output

If you've tailed the logs correctly, you will see a large JSON output to stdout of the container. That is your observable object that provides a looking glass into your request/response lifecycle of the Sidecar.

Congratulations

You have successfully created a full running instance of a Grey Matter Fabric, adding an example service, and modified the service using the Grey Matter CLI.

Questions?

Last updated

Was this helpful?