API in gateway not visible in the dashboard

Hello,
I’m trying the Tyk On-premises solution using docker. The gateway and the dashboard seem to correctly run. But on the dashboard (page : System Management > APIs), the registered APIs list is empty (Displayed message : No API configurations to display).

I started the gateway container with the following tyk.conf file :
{ "listen_port": 8888, "secret": "352d20ee67be67f6340b4c0605b044b7", "template_path": "/opt/tyk-gateway/templates", "tyk_js_path": "/opt/tyk-gateway/js/tyk.js", "use_db_app_configs": false, "app_path": "/opt/tyk-gateway/apps", "middleware_path": "/opt/tyk-gateway/middleware", "storage": { "type": "redis", "host": "localhost", "port": 6379, "username": "", "password": "", "database": 0, "optimisation_max_idle": 2000, "optimisation_max_active": 4000 }, "enable_analytics": false, "analytics_config": { "type": "csv", "pool_size": 100, "csv_dir": "/tmp", "mongo_url": "", "mongo_db_name": "", "mongo_collection": "", "purge_delay": -1, "ignored_ips": [], "normalise_urls": { "enabled": true, "normalise_uuids": true, "normalise_numbers": true, "custom_patterns": [] } }, "health_check": { "enable_health_checks": true, "health_check_value_timeouts": 60 }, "optimisations_use_async_session_write": true, "allow_master_keys": false, "policies": { "policy_source": "file", "policy_record_name": "policies" }, "hash_keys": true, "suppress_redis_signal_reload": false, "close_connections": true, "enable_non_transactional_rate_limiter": true, "enable_sentinel_rate_limiter": false, "local_session_cache": { "disable_cached_session_state": false }, "uptime_tests": { "disable": false, "config": { "enable_uptime_analytics": false, "failure_trigger_sample_size": 2, "time_wait": 10, "checker_pool_size": 50 } }, "http_server_options": { "enable_websockets": true }, "hostname": "", "enable_custom_domains": true, "enable_jsvm": true, "oauth_redirect_uri_separator": ";", "coprocess_options": { "enable_coprocess": false, "coprocess_grpc_server": "" }, "pid_file_location": "./tyk-gateway.pid", "allow_insecure_configs": true, "public_key_path": "", "close_idle_connections": false, "allow_remote_config": false, "enable_bundle_downloader": true, "bundle_base_url": "", "global_session_lifetime": 100, "force_global_session_lifetime": false, "max_idle_connections_per_host": 100 }

and start the dashboard with the following tyk_analytics.conf file :
{ "listen_port": 3000, "tyk_api_config": { "Host": "http://localhost", "Port": "8888", "Secret": "352d20ee67be67f6340b4c0605b044b7" }, "mongo_url": "mongodb://mongo:27017/tyk_analytics", "mongo_use_ssl": false, "mongo_ssl_insecure_skip_verify": false, "page_size": 10, "admin_secret": "12345", "shared_node_secret": "352d20ee67be67f6340b4c0605b044b7", "redis_port": 6379, "redis_host": "redis", "redis_password": "", "enable_cluster": false, "force_api_defaults": false, "notify_on_change": true, "redis_database": 0, "redis_hosts": null, "hash_keys": true, "email_backend": { "enable_email_notifications": false, "code": "", "settings": null, "default_from_email": "", "default_from_name": "", "dashboard_hostname": "" }, "hide_listen_path": false, "sentry_code": "", "sentry_js_code": "", "use_sentry": false, "enable_master_keys": false, "enable_duplicate_slugs": true, "show_org_id": true, "host_config": { "enable_host_names": true, "disable_org_slug_prefix": true, "hostname": "dashboard.tyk.docker", "override_hostname": "tyk.docker", "portal_domains": {}, "portal_root_path": "/portal", "generate_secure_paths": false, "secure_cookies": false, "use_strict_hostmatch": false }, "http_server_options": { "use_ssl": false, "certificates": [ { "domain_name": "", "cert_file": "", "key_file": "" } ], "min_version": 0 }, "security": { "allow_admin_reset_password": false, "login_failure_username_limit": 0, "login_failure_ip_limit": 0, "login_failure_expiration": 0, "audit_log_path": "" }, "ui": { "languages": null, "hide_help": false, "default_lang": "", "login_page": {}, "nav": {}, "uptime": {}, "portal_section": null, "designer": {}, "dont_show_admin_sockets": false, "dont_allow_license_management": false, "dont_allow_license_management_view": false }, "home_dir": "/opt/tyk-dashboard", "identity_broker": { "enabled": false, "host": { "connection_string": "", "secret": "" } }, "tagging_options": { "tag_all_apis_by_org": false }, "use_sharded_analytics": false, "enable_aggregate_lookups": true, "enable_analytics_cache": false, "aggregate_lookup_cutoff": "01/07/2016", "maintenance_mode": false, "allow_explicit_policy_id": false, "private_key_path": "", "node_schema_path": "", "oauth_redirect_uri_separator": "", "statsd_connection_string": "", "statsd_prefix": "", "disable_parallel_sessions": false, "dashboard_session_lifetime": 0 }
When I request the gateway, I correctly have the api definition :
$ curl -H "x-tyk-authorization: 352d20ee67be67f6340b4c0605b044b7" http://localhost:8888/tyk/apis/1
{"name":"Test API","slug":"test-api","api_id":"1","org_id":"1","use_keyless":false,"use_oauth2":false,"use_openid":false,"openid_options":{"providers":null,"segregate_by_client":false},"oauth_meta":{"allowed_access_types":null,"allowed_authorize_types":null,"auth_login_redirect":""},"auth":{"use_param":false,"param_name":"","use_cookie":false,"cookie_name":"","auth_header_name":"Authorization"},"use_basic_auth":false,"enable_jwt":false,"use_standard_auth":false,"enable_coprocess_auth":false,"jwt_signing_method":"","jwt_source":"","jwt_identity_base_field":"","jwt_client_base_field":"","jwt_policy_field_name":"","notifications":{"shared_secret":"","oauth_on_keychange_url":""},"enable_signature_checking":false,"hmac_allowed_clock_skew":0,"base_identity_provided_by":"","definition":{"location":"header","key":"x-api-version"},"version_data":{"not_versioned":true,"versions":{"Default":{"name":"Default","expires":"","paths":{"ignored":null,"white_list":null,"black_list":null},"use_extended_paths":true,"extended_paths":{},"global_headers":null,"global_headers_remove":null,"global_size_limit":0,"override_target":""}}},"uptime_tests":{"check_list":null,"config":{"expire_utime_after":0,"service_discovery":{"use_discovery_service":false,"query_endpoint":"","use_nested_query":false,"parent_data_path":"","data_path":"","port_data_path":"","target_path":"","use_target_list":false,"cache_timeout":0,"endpoint_returns_list":false},"recheck_wait":0}},"proxy":{"preserve_host_header":false,"listen_path":"/test-api/-1","target_url":"http://httpbin.org/","strip_listen_path":true,"enable_load_balancing":false,"target_list":null,"check_host_against_uptime_tests":false,"service_discovery":{"use_discovery_service":false,"query_endpoint":"","use_nested_query":false,"parent_data_path":"","data_path":"","port_data_path":"","target_path":"","use_target_list":false,"cache_timeout":0,"endpoint_returns_list":false}},"disable_rate_limit":false,"disable_quota":false,"custom_middleware":{"pre":null,"post":null,"post_key_auth":null,"auth_check":{"name":"","path":"","require_session":false},"response":null,"driver":"","id_extractor":{"extract_from":"","extract_with":"","extractor_config":null}},"custom_middleware_bundle":"","cache_options":{"cache_timeout":0,"enable_cache":false,"cache_all_safe_requests":false,"cache_response_codes":null,"enable_upstream_cache_control":false},"session_lifetime":0,"active":true,"auth_provider":{"name":"","storage_engine":"","meta":null},"session_provider":{"name":"","storage_engine":"","meta":null},"event_handlers":{"events":null},"enable_batch_request_support":false,"enable_ip_whitelisting":false,"allowed_ips":null,"dont_set_quota_on_create":false,"expire_analytics_after":0,"response_processors":null,"CORS":{"enable":false,"allowed_origins":null,"allowed_methods":null,"allowed_headers":null,"exposed_headers":null,"allow_credentials":false,"max_age":0,"options_passthrough":false,"debug":false},"domain":"","do_not_track":false,"tags":null,"enable_context_vars":false}

So when I test the api with the following request :
curl -H "Authorization: null" http://127.0.0.1:8888/test-api/-1/get
I have the following response : { "error": "Key not authorised" }.

I agree that the key is missing. But according to me, it proves that my api is registered and I don’t understand why it is not visible in the dashboard. Please, does I miss something or am I wrong anywhere ? Thanks for reply.

Hi thibaut,

is MongoDB running ?
Can you share your Dashboard logs ?
I’d also recommend to add the following to your tyk.conf

 “use_db_app_configs”: true,
    “db_app_conf_options”: {
        “connection_string”: “http://localhost:3000”,
        “node_is_segmented”: false,
        “tags”: [“test”]
}

Thanks,
Kos @ Tyk Support Team

Thibaut,

The cknfg you have shared is for a non-dashboard version, the Gateway either uses files (and no dashboard at all) or has the dashboard (and does not use files at all).

APIs that yu have loaded using files will not find their way into the dashboard, because the dashboard stores data in MongoDB and feeds data to gateways via a service.

If you want to use the dashboard, you’ll need to use the dashboard enabled config template (these can be found in the install/data directory, or here:

https://github.com/TykTechnologies/tyk/blob/master/install/data/tyk.with_dash.conf

M.

OK, Thanks for reply.

So I will use the dashboard instead of configuration files. But I’m facing another problem.
I replaced my previous tyk.conf file by a file based on the tyk.with_dash.conf template. I also corrected my tyk_analytics.conf file.

I created an API in the dashboard with the listen path /httpbin/. But the curl -v http://localhost:8080/httpbin/ command is pending (no response).
In the gateway logs, I have may connection errors :
time="Sep 13 08:57:58" level=debug msg="Notifier will not work in hybrid mode" time="Sep 13 08:57:58" level=debug msg="Storage Engine already initialised..." time="Sep 13 08:57:58" level=info msg="Setting up analytics normaliser" time="Sep 13 08:57:58" level=info msg="PIDFile location set to: ./tyk-gateway.pid" time="Sep 13 08:57:58" level=error msg="Instrumentation is enabled, but no connectionstring set for statsd" time="Sep 13 08:57:58" level=info msg="Initialising Tyk REST API Endpoints" time="Sep 13 08:57:58" level=info msg="--> Standard listener (http)" time="Sep 13 08:57:58" level=info msg="Setting up Server" time="Sep 13 08:57:58" level=info msg="Registering node." time="Sep 13 08:57:58" level=info msg="Starting Poller" time="Sep 13 08:57:58" level=error msg="Request failed: Get http://localhost:3000/register/node: dial tcp 127.0.0.1:3000: getsockopt: connection refused" time="Sep 13 08:58:03" level=warning msg="Insecure configuration detected (allowing)!" time="Sep 13 08:58:03" level=info msg="Hostname set with dashboard zeroconf signal" time="Sep 13 08:58:03" level=error msg="Request failed: Get http://localhost:3000/register/node: dial tcp 127.0.0.1:3000: getsockopt: connection refused" time="Sep 13 08:58:08" level=error msg="Request failed: Get http://localhost:3000/register/node: dial tcp 127.0.0.1:3000: getsockopt: connection refused" time="Sep 13 08:58:13" level=error msg="Request failed: Get http://localhost:3000/register/node: dial tcp 127.0.0.1:3000: getsockopt: connection refused"

On the dashboard side, it seems ok :
time="Sep 13 08:58:03" level=info msg="Copyright Martin Buhr 2016" time="Sep 13 08:58:03" level=info msg="https://www.tyk.io" time="Sep 13 08:58:03" level=info msg="Listening on port: 3000" time="Sep 13 08:58:03" level=info msg="Loading routes..." time="Sep 13 08:58:03" level=info msg="Registering nodes..." time="Sep 13 08:58:03" level=info msg="Adding available nodes..." time="Sep 13 08:58:03" level=info msg="Creating new Redis connection pool" time="Sep 13 08:58:03" level=info msg="Socket server started" time="Sep 13 08:58:03" level=info msg="--> Standard listener (http) for UI notifications" time="Sep 13 08:58:03" level=debug msg="Starting channel copy" time="Sep 13 08:58:03" level=info msg="--> Standard listener (http) for dashboard and API" time="Sep 13 08:58:03" level=info msg="Starting zeroconf heartbeat" time="Sep 13 08:58:03" level=info msg="Starting notification handler for gateway cluster" time="Sep 13 08:58:03" level=debug msg="Sending notification{NoticeDashboardZeroConf {\"DashboardConfig\":{\"Hostname\":\"localhost\",\"Port\":3000,\"UseTLS\":false},\"TimeStamp\":1505293083} }" time="Sep 13 08:58:03" level=debug msg="Subscription started: tyk.cluster.notifications" time="Sep 13 08:58:03" level=debug msg="Subscription started: dashboard.ui.messages" time="Sep 13 08:58:05" level=debug msg="Sending notification{NoticeDashboardZeroConf {\"DashboardConfig\":{\"Hostname\":\"localhost\",\"Port\":3000,\"UseTLS\":false},\"TimeStamp\":1505293085} }" time="Sep 13 08:58:07" level=debug msg="Sending notification{NoticeDashboardZeroConf {\"DashboardConfig\":{\"Hostname\":\"localhost\",\"Port\":3000,\"UseTLS\":false},\"TimeStamp\":1505293087} }" time="Sep 13 08:58:09" level=debug msg="Sending notification{NoticeDashboardZeroConf {\"DashboardConfig\":{\"Hostname\":\"localhost\",\"Port\":3000,\"UseTLS\":false},\"TimeStamp\":1505293089} }"
Please, could you tell me why my API does not respond ?

Thibaut


tyk.conf file :
{ "listen_port": 8080, "node_secret": "352d20ee67be67f6340b4c0605b044b7", "secret": "352d20ee67be67f6340b4c0605b044b7", "template_path": "/opt/tyk-gateway/templates", "tyk_js_path": "/opt/tyk-gateway/js/tyk.js", "use_db_app_configs": true, "db_app_conf_options": { "connection_string": "http://localhost:3000", "node_is_segmented": false, "tags": [] }, "disable_dashboard_zeroconf": false, "app_path": "/opt/tyk-gateway/apps", "middleware_path": "/opt/tyk-gateway/middleware", "storage": { "type": "redis", "host": "redis", "port": 6379, "username": "", "password": "", "database": 0, "optimisation_max_idle": 2000, "optimisation_max_active": 4000 }, "enable_analytics": true, "analytics_config": { "type": "mongo", "pool_size": 100, "csv_dir": "/tmp", "mongo_url": "", "mongo_db_name": "", "mongo_collection": "", "purge_delay": 100, "ignored_ips": [], "enable_detailed_recording": true, "enable_geo_ip": false, "geo_ip_db_path": "", "normalise_urls": { "enabled": true, "normalise_uuids": true, "normalise_numbers": true, "custom_patterns": [] } }, "health_check": { "enable_health_checks": false, "health_check_value_timeouts": 60 }, "optimisations_use_async_session_write": true, "allow_master_keys": false, "policies": { "policy_source": "service", "policy_connection_string": "", "policy_record_name": "tyk_policies", "allow_explicit_policy_id": true }, "hash_keys": true, "suppress_redis_signal_reload": false, "use_redis_log": true, "close_connections": true, "enable_non_transactional_rate_limiter": true, "enable_sentinel_rate_limiter": false, "experimental_process_org_off_thread": true, "local_session_cache": { "disable_cached_session_state": false }, "http_server_options": { "enable_websockets": true }, "uptime_tests": { "disable": false, "config": { "enable_uptime_analytics": true, "failure_trigger_sample_size": 2, "time_wait": 10, "checker_pool_size": 50 } }, "hostname": "", "enable_custom_domains": true, "enable_jsvm": true, "oauth_redirect_uri_separator": ";", "coprocess_options": { "enable_coprocess": false, "coprocess_grpc_server": "" }, "pid_file_location": "./tyk-gateway.pid", "allow_insecure_configs": true, "public_key_path": "", "close_idle_connections": false, "allow_remote_config": false, "enable_bundle_downloader": true, "bundle_base_url": "", "global_session_lifetime": 100, "force_global_session_lifetime": false, "max_idle_connections_per_host": 100 }

tyk_analytics.conf file :
{ "listen_port": 3000, "tyk_api_config": { "Host": "http://localhost", "Port": "8080", "Secret": "352d20ee67be67f6340b4c0605b044b7" }, "mongo_url": "mongodb://mongo:27017/tyk_analytics", "mongo_use_ssl": false, "mongo_ssl_insecure_skip_verify": false, "page_size": 10, "admin_secret": "12345", "shared_node_secret": "352d20ee67be67f6340b4c0605b044b7", "redis_port": 6379, "redis_host": "redis", "redis_password": "", "enable_cluster": false, "force_api_defaults": false, "notify_on_change": true, "license_key": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhbGxvd2VkX25vZGVzIjoiZGQ5ODgzODctNGRlOS00ZWJiLTU3NjAtNzViNzY4ZTliOGE1IiwiZXhwIjoxNTMzMTMwOTkxLCJvd25lciI6IjU5ODA4NTZmNDVmOTJlMWI3NzBiMGU2MiJ9.nLJlK3n_Ka71SJvVOsobN00NWyOWL4a0br0jjZPad3IKfTltrJYIqfql48wqvoffDByk10EjT600_nokgC04ya69QZz7dqiR-EiA08ELewSSBDEAHAT3AH5LuNkLDcdzo9GKLEFSnkxDYMlGNm4bwRaLZybKCLwh7CSK7xJ1letVV_b2-TubLZE83zZdt5G1w3YQE-9xaWd8X7c7M-3uoHTQFbocLDqJEdjENTJWvCE85YW3fr9Y2kALOIyiHxWGq_Y1AFlqw6c2tW7CYDNEZPIXdIkGqDSgD39w9wHs_HGaTiqc9iJ8W3UtLfw2AhP3oIvj_uuAPEti5_f8EW_6Zw", "redis_database": 0, "redis_hosts": null, "hash_keys": true, "email_backend": { "enable_email_notifications": false, "code": "", "settings": null, "default_from_email": "", "default_from_name": "", "dashboard_hostname": "" }, "hide_listen_path": false, "sentry_code": "", "sentry_js_code": "", "use_sentry": false, "enable_master_keys": false, "enable_duplicate_slugs": true, "show_org_id": true, "host_config": { "enable_host_names": true, "disable_org_slug_prefix": true, "hostname": "localhost", "override_hostname": "tyk.docker", "portal_domains": {}, "portal_root_path": "/portal", "generate_secure_paths": false, "secure_cookies": false, "use_strict_hostmatch": false }, "http_server_options": { "use_ssl": false, "certificates": [ { "domain_name": "", "cert_file": "", "key_file": "" } ], "min_version": 0 }, "security": { "allow_admin_reset_password": false, "login_failure_username_limit": 0, "login_failure_ip_limit": 0, "login_failure_expiration": 0, "audit_log_path": "" }, "ui": { "languages": null, "hide_help": false, "default_lang": "", "login_page": {}, "nav": {}, "uptime": {}, "portal_section": null, "designer": {}, "dont_show_admin_sockets": false, "dont_allow_license_management": false, "dont_allow_license_management_view": false }, "home_dir": "/opt/tyk-dashboard", "identity_broker": { "enabled": false, "host": { "connection_string": "", "secret": "" } }, "tagging_options": { "tag_all_apis_by_org": false }, "use_sharded_analytics": false, "enable_aggregate_lookups": true, "enable_analytics_cache": false, "aggregate_lookup_cutoff": "01/07/2016", "maintenance_mode": false, "allow_explicit_policy_id": false, "private_key_path": "", "node_schema_path": "", "oauth_redirect_uri_separator": "", "statsd_connection_string": "", "statsd_prefix": "", "disable_parallel_sessions": false, "dashboard_session_lifetime": 0 }

Hi Thibault,

I got similar errors with this db config set as yours is:

"use_db_app_configs": true,
"db_app_conf_options": {
"connection_string": "http://localhost:3000",
"node_is_segmented": false,
"tags": []
}

Try changing the connection-string so it looks like this:

"use_db_app_configs": true,
    "db_app_conf_options": {
        "connection_string": "http://tyk_dashboard:3000",
        "node_is_segmented": false,
        "tags": ["test2"]
    }

Let me know if this changes your logs at all.

Regards
Josh

Ok. I’ve got the point. My docker network didn’t manage to resolve the address names (localhost or tyk_dashboard). I fixed it replacing the hostnames in my config files by the private urls from docker. Creepy solution : it will be better to correct the docker network configuration.

Hi

Glad you got it sorted!

Did you change the docker configuration and container names?