MariaDB Maxscale REST API – Unable to Show Result

apijsonmariadbmaxscale

hi i have already setup maxadmin on maxscale can access from rest api this is my configuration

    .....
[CLI_Service]
type=service
router=cli

[CLI_Listener]
type=listener
service=CLI_Service
protocol=maxscaled
address=192.168.101.107
socket=default

[MaxAdmin_Inet]
type=listener
service=CLI_Service
protocol=HTTPD
address=192.168.101.107
port=8010

but when i test the url like this

curl --include --basic --user "admin:mariadb" http://192.168.101.107:8010/v1/servers

the result is like this

HTTP/1.1 200 OK
Date: Wed, 13 May 2020 11:33:15 GMT
Server: MaxScale(c) v.1.0.0
Connection: close
WWW-Authenticate: Basic realm="MaxInfo"
Content-Type: application/json

Commands must consist of at least two words. Type help for a list of commands

whether i miss about the configuration ?

Best Answer

already got for default configuration when you need enable rest api maxscale

the tag must be [maxscale] and this is part when you need enable rest api for maxscale

[maxscale]
...
admin_host=192.168.101.107
admin_port=8989
admin_auth=1
admin_enabled=1

admin_host as your physical ip server

and then after you restart maxscale service, command maxctrl list servers or anything else can't run normally they need run command like this maxctrl -h 192.168.101.107:8989 list servers

and then you need test rest api

curl --include --basic --user "admin:mariadb" http://192.168.101.107:8010/v1/servers

and this is the results

HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 13156
Last-Modified: Wed, 13 May 2020 05:56:59 GMT
ETag: "0"
Date: Wed, 13 May 20 08:42:51 GMT
Content-Type: application/json

{
    "links": {
        "self": "http://192.168.101.107:8989/v1/servers/"
    },
    "data": [
        {
            "id": "server67",
            "type": "servers",
            "relationships": {
                "services": {
                    "links": {
                        "self": "http://192.168.101.107:8989/v1/services/"
                    },
                    "data": [
                        {
                            "id": "Read-Write-Service",
                            "type": "services"
                        }
                    ]
                },
                "monitors": {
                    "links": {
                        "self": "http://192.168.101.107:8989/v1/monitors/"
                    },
                    "data": [
                        {
                            "id": "MariaDB-Monitor",
                            "type": "monitors"
                        }
                    ]
                }
            },
            "attributes": {
                "parameters": {
                    "address": "192.168.101.67",
                    "socket": null,
                    "protocol": "MySQLBackend",
                    "port": 3306,
                    "extra_port": 0,
                    "authenticator": null,
                    "monitoruser": null,
                    "monitorpw": null,
                    "persistpoolmax": 0,
                    "persistmaxtime": 0,
                    "proxy_protocol": false,
                    "ssl": "false",
                    "ssl_cert": null,
                    "ssl_key": null,
                    "ssl_ca_cert": null,
                    "ssl_version": "MAX",
                    "ssl_cert_verify_depth": 9,
                    "ssl_verify_peer_certificate": false,
                    "disk_space_threshold": null,
                    "rank": "primary",
                    "serv_weight": "1"
                },
.......................