arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

MaxScale Filter Resource

Configure database traffic filters programmatically. This resource enables you to retrieve, create, and modify filter instances and their runtime parameters.

hashtag
Overview

A filter resource represents an instance of a filter inside MaxScale. Multiple services can use the same filter and a single service can use multiple filters.

hashtag
Resource Operations

The :name in all of the URIs must be the name of a filter in MaxScale.

hashtag
Get a filter

Get a single filter.

hashtag
Response

Status: 200 OK

hashtag
Get all filters

Get all filters.

hashtag
Response

Status: 200 OK

hashtag
Get filter relationships

The :type in the URI must be services as filters only have service relationships.

hashtag
Response

Status: 200 OK

hashtag
Create a filter

Create a new filter. The posted object must define at least the following fields.

  • data.id

    • Name of the filter

  • data.type

All of the filter parameters should be defined at creation time in the data.attributes.parameters object.

As the service to filter relationship is ordered (filters are applied in the order they are listed), filter to service relationships cannot be defined at creation time.

The following example defines a request body which creates a new filter.

hashtag
Response

Filter is created:

Status: 204 No Content

hashtag
Update a filter

Filter parameters can be updated at runtime if the module supports it. Refer to the individual module documentation for more details on whether it supports runtime configuration and which parameters can be updated.

The following example modifies a filter by changing the match parameter to .*users.*.

hashtag
Response

Filter is modified:

Status: 204 No Content

hashtag
Destroy a filter

The :filter in the URI must map to the name of the filter to be destroyed.

A filter can only be destroyed if no service uses it. This means that the data.relationships object for the filter must be empty. Note that the service → filter relationship cannot be modified from the filters resource and must be done via the services resource.

This endpoint also supports the force=yes parameter that will unconditionally delete the filter by first removing it from all services that it uses.

hashtag
Response

Filter is destroyed:

Status: 204 No Content

This page is licensed: CC BY-SA / Gnu FDL

Type of the object, must be filters

  • data.attributes.module

    • The filter module to use

  • spinner
    GET /v1/filters/:name
    {
        "data": {
            "attributes": {
                "module": "qlafilter",
                "parameters": {
                    "append": false,
                    "duration_unit": "ms",
                    "exclude": null,
                    "filebase": "/tmp/qla.log",
                    "flush": true,
                    "log_data": "date,user,query",
                    "log_type": "unified",
                    "match": null,
                    "module": "qlafilter",
                    "newline_replacement": " ",
                    "options": "",
                    "separator": ",",
                    "source": null,
                    "source_exclude": null,
                    "source_match": null,
                    "use_canonical_form": false,
                    "user": null,
                    "user_exclude": null,
                    "user_match": null
                },
                "source": {
                    "file": "/etc/maxscale.cnf",
                    "type": "static"
                }
            },
            "id": "QLA",
            "links": {
                "self": "http://localhost:8989/v1/filters/QLA/"
            },
            "relationships": {
                "services": {
                    "data": [
                        {
                            "id": "Read-Connection-Router",
                            "type": "services"
                        }
                    ],
                    "links": {
                        "related": "http://localhost:8989/v1/services/",
                        "self": "http://localhost:8989/v1/filters/QLA/relationships/services/"
                    }
                }
            },
            "type": "filters"
        },
        "links": {
            "self": "http://localhost:8989/v1/filters/QLA/"
        }
    }
    GET /v1/filters
    {
        "data": [
            {
                "attributes": {
                    "module": "qlafilter",
                    "parameters": {
                        "append": false,
                        "duration_unit": "ms",
                        "exclude": null,
                        "filebase": "/tmp/qla.log",
                        "flush": true,
                        "log_data": "date,user,query",
                        "log_type": "unified",
                        "match": null,
                        "module": "qlafilter",
                        "newline_replacement": " ",
                        "options": "",
                        "separator": ",",
                        "source": null,
                        "source_exclude": null,
                        "source_match": null,
                        "use_canonical_form": false,
                        "user": null,
                        "user_exclude": null,
                        "user_match": null
                    },
                    "source": {
                        "file": "/etc/maxscale.cnf",
                        "type": "static"
                    }
                },
                "id": "QLA",
                "links": {
                    "self": "http://localhost:8989/v1/filters/QLA/"
                },
                "relationships": {
                    "services": {
                        "data": [
                            {
                                "id": "Read-Connection-Router",
                                "type": "services"
                            }
                        ],
                        "links": {
                            "related": "http://localhost:8989/v1/services/",
                            "self": "http://localhost:8989/v1/filters/QLA/relationships/services/"
                        }
                    }
                },
                "type": "filters"
            },
            {
                "attributes": {
                    "module": "hintfilter",
                    "parameters": {
                        "module": "hintfilter"
                    },
                    "source": {
                        "file": "/etc/maxscale.cnf",
                        "type": "static"
                    }
                },
                "id": "Hint",
                "links": {
                    "self": "http://localhost:8989/v1/filters/Hint/"
                },
                "relationships": {
                    "services": {
                        "data": [
                            {
                                "id": "Read-Connection-Router",
                                "type": "services"
                            }
                        ],
                        "links": {
                            "related": "http://localhost:8989/v1/services/",
                            "self": "http://localhost:8989/v1/filters/Hint/relationships/services/"
                        }
                    }
                },
                "type": "filters"
            }
        ],
        "links": {
            "self": "http://localhost:8989/v1/filters/"
        }
    }
    GET /v1/filters/:name/relationships/:type
    {
        "data": [
            {
                "id": "Read-Connection-Router",
                "type": "services"
            }
        ],
        "links": {
            "related": "http://localhost:8989/v1/services/",
            "self": "http://localhost:8989/v1/filters/QLA/relationships/services/"
        }
    }
    POST /v1/filters
    {
        "data": {
            "id": "test-filter", // Name of the filter
            "type": "filters",
            "attributes": {
                "module": "qlafilter", // The filter uses the qlafilter module
                "parameters": { // Filter parameters
                    "filebase": "/tmp/qla.log"
                }
            }
        }
    }
    PATCH /v1/filters/:name
    {
        "data": {
            "attributes": {
                "parameters": {
                    "match": ".*users.*"
                }
            }
        }
    }
    DELETE /v1/filters/:filter