emqx_dashboard.hrl 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. %%--------------------------------------------------------------------
  2. %% Copyright (c) 2020-2024 EMQ Technologies Co., Ltd. All Rights Reserved.
  3. %%
  4. %% Licensed under the Apache License, Version 2.0 (the "License");
  5. %% you may not use this file except in compliance with the License.
  6. %% You may obtain a copy of the License at
  7. %%
  8. %% http://www.apache.org/licenses/LICENSE-2.0
  9. %%
  10. %% Unless required by applicable law or agreed to in writing, software
  11. %% distributed under the License is distributed on an "AS IS" BASIS,
  12. %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. %% See the License for the specific language governing permissions and
  14. %% limitations under the License.
  15. %%--------------------------------------------------------------------
  16. -include("emqx_dashboard_rbac.hrl").
  17. -define(ADMIN, emqx_admin).
  18. -define(BACKEND_LOCAL, local).
  19. -define(SSO_USERNAME(Backend, Name), {Backend, Name}).
  20. -type dashboard_sso_backend() :: atom().
  21. -type dashboard_sso_username() :: {dashboard_sso_backend(), binary()}.
  22. -type dashboard_username() :: binary() | dashboard_sso_username().
  23. -type dashboard_user_role() :: binary().
  24. -record(?ADMIN, {
  25. username :: dashboard_username(),
  26. pwdhash :: binary(),
  27. description :: binary(),
  28. role = ?ROLE_DEFAULT :: dashboard_user_role(),
  29. extra = #{} :: map()
  30. }).
  31. -type dashboard_user() :: #?ADMIN{}.
  32. -define(ADMIN_JWT, emqx_admin_jwt).
  33. -record(?ADMIN_JWT, {
  34. token :: binary(),
  35. username :: binary(),
  36. exptime :: integer(),
  37. extra = #{} :: map()
  38. }).
  39. -define(TAB_COLLECT, emqx_collect).
  40. -define(EMPTY_KEY(Key), ((Key == undefined) orelse (Key == <<>>))).
  41. -define(DASHBOARD_SHARD, emqx_dashboard_shard).
  42. -ifdef(TEST).
  43. %% for test
  44. -define(DEFAULT_SAMPLE_INTERVAL, 1).
  45. -define(RPC_TIMEOUT, 50).
  46. -else.
  47. %% dashboard monitor do sample interval, default 10s
  48. -define(DEFAULT_SAMPLE_INTERVAL, 10).
  49. -define(RPC_TIMEOUT, 5000).
  50. -endif.
  51. -define(DELTA_SAMPLER_LIST, [
  52. received,
  53. %, received_bytes
  54. sent,
  55. %, sent_bytes
  56. validation_succeeded,
  57. validation_failed,
  58. dropped,
  59. persisted
  60. ]).
  61. -define(GAUGE_SAMPLER_LIST, [
  62. subscriptions,
  63. topics,
  64. connections,
  65. live_connections
  66. ]).
  67. -define(SAMPLER_LIST, ?GAUGE_SAMPLER_LIST ++ ?DELTA_SAMPLER_LIST).
  68. -define(DELTA_SAMPLER_RATE_MAP, #{
  69. received => received_msg_rate,
  70. %% In 5.0.0, temporarily comment it to suppress bytes rate
  71. %received_bytes => received_bytes_rate,
  72. %sent_bytes => sent_bytes_rate,
  73. sent => sent_msg_rate,
  74. validation_succeeded => validation_succeeded_rate,
  75. validation_failed => validation_failed_rate,
  76. dropped => dropped_msg_rate,
  77. persisted => persisted_rate
  78. }).
  79. -define(CURRENT_SAMPLE_NON_RATE,
  80. [
  81. node_uptime,
  82. retained_msg_count,
  83. shared_subscriptions
  84. ] ++ ?LICENSE_QUOTA
  85. ).
  86. -if(?EMQX_RELEASE_EDITION == ee).
  87. -define(LICENSE_QUOTA, [license_quota]).
  88. -else.
  89. -define(LICENSE_QUOTA, []).
  90. -endif.