keephq / keep

The open-source alert management and AIOps platform
https://keephq.dev
Other
4.95k stars 701 forks source link

Cannot add zabbix provider #499

Closed cbistv2 closed 1 year ago

cbistv2 commented 1 year ago

Describe the bug When adding zabbix provider the following error is presented:

Scopes are invalid for zabbix: undefined

despite following https://docs.keephq.dev/providers/documentation/zabbix-provider to the letter other providers work fine even when running locally.

the docker logs shows a long stacktrace with not a lot of usefull information expect:

File \"/venv/lib/python3.11/site-packages/keep/providers/zabbix_provider/zabbix_provider.py\", line 280, in validate_scopes\n error = e.args[0][\"data\"]\n ~~~~~^^^^^^^^\nTypeError: string indices must be integers, not 'str'", "otelTraceSampled": false}

which indicate that https://github.com/keephq/keep/blob/main/keep/providers/zabbix_provider/zabbix_provider.py dosent handle errors corretly to me.

Zabbix version: 6.4

To Reproduce Steps to reproduce the behavior:

  1. Run the keep stack using docker compose from https://raw.githubusercontent.com/keephq/keep/main/docker-compose.yml
  2. Click on the zabbix provider under "Available Providers"
  3. Fill out required information
  4. See error

Expected behavior the zabbix provider being added correctly

Additional context I'll post the entire stack trace here:

keep-backend-1 | {"asctime": "2023-11-14 12:46:57,817", "message": "Installing provider", "levelname": "INFO", "name": "keep.api.routes.providers", "filename": "providers.py", "otelTraceID": "2ec5858fbf6d2471813e97be336e4b96", "otelSpanID": "baf21d4f8c5cc288", "otelServiceName": "keep-api", "otelTraceSampled": true, "provider_id": "zabbix", "provider_type": "zabbix", "tenant_id": "keep"} keep-backend-1 | {"asctime": "2023-11-14 12:46:58,502", "message": "An unhandled exception occurred: string indices must be integers, not 'str', Trace ID: 2ec5858fbf6d2471813e97be336e4b96", "levelname": "ERROR", "name": "root", "filename": "api.py", "otelTraceID": "0", "otelSpanID": "0", "otelServiceName": "keep-api", "otelTraceSampled": false} keep-backend-1 | {"asctime": "2023-11-14 12:46:58,502", "message": "172.18.0.3:45898 - \"POST /providers/install HTTP/1.1\" 500", "levelname": "INFO", "name": "uvicorn.access", "filename": "h11_impl.py", "otelTraceID": "0", "otelSpanID": "0", "otelServiceName": "keep-api", "otelTraceSampled": false} keep-backend-1 | {"asctime": "2023-11-14 12:46:58,503", "message": "Exception in ASGI application\n", "levelname": "ERROR", "name": "uvicorn.error", "filename": "logging.py", "otelTraceID": "2ec5858fbf6d2471813e97be336e4b96", "otelSpanID": "0", "otelServiceName": "keep-api", "exc_info": "Traceback (most recent call last):\n File \"/venv/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py\", line 407, in run_asgi\n result = await app( # type: ignore[func-returns-value]\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py\", line 78, in call\n return await self.app(scope, receive, send)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib/python3.11/site-packages/uvicorn/middleware/message_logger.py\", line 86, in call\n raise exc from None\n File \"/venv/lib/python3.11/site-packages/uvicorn/middleware/message_logger.py\", line 82, in call\n await self.app(scope, inner_receive, inner_send)\n File \"/venv/lib/python3.11/site-packages/fastapi/applications.py\", line 271, in call\n await super().call(scope, receive, send)\n File \"/venv/lib/python3.11/site-packages/starlette/applications.py\", line 118, in call\n await self.middleware_stack(scope, receive, send)\n File \"/venv/lib/python3.11/site-packages/starlette/middleware/errors.py\", line 184, in call\n raise exc\n File \"/venv/lib/python3.11/site-packages/starlette/middleware/errors.py\", line 162, in call\n await self.app(scope, receive, _send)\n File \"/venv/lib/python3.11/site-packages/opentelemetry/instrumentation/asgi/init.py\", line 596, in call\n await self.app(scope, otel_receive, otel_send)\n File \"/venv/lib/python3.11/site-packages/starlette/middleware/base.py\", line 108, in call\n response = await self.dispatch_func(request, call_next)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib/python3.11/site-packages/keep/api/observability.py\", line 74, in call\n response = await call_next(request)\n ^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib/python3.11/site-packages/starlette/middleware/base.py\", line 84, in call_next\n raise app_exc\n File \"/venv/lib/python3.11/site-packages/starlette/middleware/base.py\", line 70, in coro\n await self.app(scope, receive_or_disconnect, send_no_error)\n File \"/venv/lib/python3.11/site-packages/starlette/middleware/gzip.py\", line 24, in call\n await responder(scope, receive, send)\n File \"/venv/lib/python3.11/site-packages/starlette/middleware/gzip.py\", line 44, in call\n await self.app(scope, receive, self.send_with_gzip)\n File \"/venv/lib/python3.11/site-packages/starlette/middleware/base.py\", line 108, in call\n response = await self.dispatch_func(request, call_next)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib/python3.11/site-packages/keep/api/api.py\", line 105, in dispatch\n response = await call_next(request)\n ^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib/python3.11/site-packages/starlette/middleware/base.py\", line 84, in call_next\n raise app_exc\n File \"/venv/lib/python3.11/site-packages/starlette/middleware/base.py\", line 70, in coro\n await self.app(scope, receive_or_disconnect, send_no_error)\n File \"/venv/lib/python3.11/site-packages/starlette/middleware/cors.py\", line 92, in call\n await self.simple_response(scope, receive, send, request_headers=headers)\n File \"/venv/lib/python3.11/site-packages/starlette/middleware/cors.py\", line 147, in simple_response\n await self.app(scope, receive, send)\n File \"/venv/lib/python3.11/site-packages/starlette_context/middleware/raw_middleware.py\", line 92, in call\n await self.app(scope, receive, send_wrapper)\n File \"/venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py\", line 79, in call\n raise exc\n File \"/venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py\", line 68, in call\n await self.app(scope, receive, sender)\n File \"/venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py\", line 21, in call\n raise e\n File \"/venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py\", line 18, in call\n await self.app(scope, receive, send)\n File \"/venv/lib/python3.11/site-packages/starlette/routing.py\", line 706, in call\n await route.handle(scope, receive, send)\n File \"/venv/lib/python3.11/site-packages/starlette/routing.py\", line 276, in handle\n await self.app(scope, receive, send)\n File \"/venv/lib/python3.11/site-packages/starlette/routing.py\", line 66, in app\n response = await func(request)\n ^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib/python3.11/site-packages/fastapi/routing.py\", line 237, in app\n raw_response = await run_endpoint_function(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib/python3.11/site-packages/fastapi/routing.py\", line 163, in run_endpoint_function\n return await dependant.call(**values)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib/python3.11/site-packages/keep/api/routes/providers.py\", line 460, in install_provider\n validated_scopes = validate_scopes(provider)\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib/python3.11/site-packages/keep/api/routes/providers.py\", line 278, in validate_scopes\n validated_scopes = provider.validate_scopes()\n ^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib/python3.11/site-packages/keep/providers/zabbix_provider/zabbix_provider.py\", line 280, in validate_scopes\n error = e.args[0][\"data\"]\n ~~~~~^^^^^^^^\nTypeError: string indices must be integers, not 'str'", "otelTraceSampled": false} keep-backend-1 | {"asctime": "2023-11-14 12:47:16,399", "message": "Authenticating", "levelname": "INFO", "name": "keep.api.core.dependencies", "filename": "dependencies.py", "otelTraceID": "b1079bb30d8275ccfaa436f0e5abcc94", "otelSpanID": "c4bb7c3123f12c33", "otelServiceName": "keep-api", "otelTraceSampled": true} keep-backend-1 | {"asctime": "2023-11-14 12:47:16,400", "message": "Getting installed providers", "levelname": "INFO", "name": "keep.api.routes.providers", "filename": "providers.py", "otelTraceID": "b1079bb30d8275ccfaa436f0e5abcc94", "otelSpanID": "c4bb7c3123f12c33", "otelServiceName": "keep-api", "otelTraceSampled": true, "tenant_id": "keep"} keep-backend-1 | {"asctime": "2023-11-14 12:47:16,414", "message": "Flushing Posthog events", "levelname": "INFO", "name": "keep.api.api", "filename": "api.py", "otelTraceID": "b1079bb30d8275ccfaa436f0e5abcc94", "otelSpanID": "c4bb7c3123f12c33", "otelServiceName": "keep-api", "otelTraceSampled": true} keep-backend-1 | {"asctime": "2023-11-14 12:47:17,002", "message": "Posthog events flushed", "levelname": "INFO", "name": "keep.api.api", "filename": "api.py", "otelTraceID": "b1079bb30d8275ccfaa436f0e5abcc94", "otelSpanID": "c4bb7c3123f12c33", "otelServiceName": "keep-api", "otelTraceSampled": true}

talboren commented 1 year ago

Thank you for the issue @cbistv2, would love for you to join our Slack Community (https://slack.keephq.dev/) so I can further assist you with this issue. I'm getting to it right away.

cbistv2 commented 1 year ago

Going to close this again, seems related to some local networking issue but the very broad exception handling obfuscated this so the addition in #500 Is very nice.