View Source PromEx.DashboardRenderer (PromEx v1.11.0)
This module is used to read dashboard definitions, render EEx dashboards, and ensure that requested files actually exist
Summary
Functions
This function will execute a provided function on the rendered dashboard to give the user a chance to adjust the dashboard definition.
Read the contents of a dashboard file entry. If an EEx version of the file exists,
read that, else fallback to the provided file name. For example, if the requested
dashboard file is ecto.json
, if ecto.json.eex
exists, then that will be returned.
This is more so for convenience so that you don't need to write out .eex
everywhere
given that all PromEx 1st party dashboards are EEx templates.
This function will decode the JSON dashboard using Jason
. If any errors occur during the decoding process,
the struct will be marked as having invalid JSON.
This function will merge in the provided assigns to the struct's assigns. These assigns will
then be used during the render_dashboard/1
call to render any EEx template statements.
Renders the dashboard. If it is an EEx file then the PromEx module assigns are passed. Else if it is a raw json file then it is passed through untouched.
Types
@type t() :: %PromEx.DashboardRenderer{ assigns: keyword() | nil, decoded_dashboard: map() | nil, error: tuple() | nil, file_contents: String.t(), file_type: :eex | :json | nil, full_path: term(), otp_app: term(), relative_path: String.t(), rendered_file: String.t() | nil, valid_file?: boolean(), valid_json?: boolean() | nil }
Functions
This function will execute a provided function on the rendered dashboard to give the user a chance to adjust the dashboard definition.
build(dashboard_otp_app, dashboard_relative_path, metrics_otp_app)
View Source@spec build( dashboard_otp_app :: atom(), dashboard_relative_path :: String.t(), metrics_otp_app :: atom() ) :: t()
Read the contents of a dashboard file entry. If an EEx version of the file exists,
read that, else fallback to the provided file name. For example, if the requested
dashboard file is ecto.json
, if ecto.json.eex
exists, then that will be returned.
This is more so for convenience so that you don't need to write out .eex
everywhere
given that all PromEx 1st party dashboards are EEx templates.
This function will decode the JSON dashboard using Jason
. If any errors occur during the decoding process,
the struct will be marked as having invalid JSON.
This function will merge in the provided assigns to the struct's assigns. These assigns will
then be used during the render_dashboard/1
call to render any EEx template statements.
Renders the dashboard. If it is an EEx file then the PromEx module assigns are passed. Else if it is a raw json file then it is passed through untouched.