-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support prometheus generator url (#1634)
* Support promethues generator url * Add enrichment type * Use links instead of enrichment * Some fixes * Add video links * Fix * PR Comments * PR Comments
- Loading branch information
1 parent
c3fcaae
commit dd2b6df
Showing
30 changed files
with
419 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import logging | ||
from typing import Optional | ||
from urllib.parse import ParseResult, parse_qs, urlencode, urlparse | ||
|
||
from robusta.core.model.env_vars import ROBUSTA_UI_DOMAIN | ||
|
||
|
||
PROM_GRAPH_PATH_URL: str = "/graph" | ||
PROM_GRAPH_URL_EXPR_PARAM: str = "g0.expr" | ||
|
||
|
||
def convert_prom_graph_url_to_robusta_metrics_explorer(prom_url: str, cluster_name: str, account_id: str) -> str: | ||
try: | ||
parsed_url: ParseResult = urlparse(prom_url) | ||
if parsed_url.path != PROM_GRAPH_PATH_URL: | ||
logging.warning("Failed to convert to robusta metric explorer url, url: %s not seems to be graph url", prom_url) | ||
return prom_url | ||
|
||
query_string = parse_qs(parsed_url.query) | ||
expr_params: Optional[list[str]] = query_string.get(PROM_GRAPH_URL_EXPR_PARAM) | ||
if not expr_params: | ||
logging.warning("Failed to get expr params, url: %s not seems to be graph url", prom_url) | ||
return prom_url | ||
|
||
expr = expr_params[0] | ||
params: dict[str, str] = {"query": expr, "cluster": cluster_name, "account": account_id} | ||
robusta_metrics_url: str = f"{ROBUSTA_UI_DOMAIN}/metrics-explorer?{urlencode(params)}" | ||
return robusta_metrics_url | ||
except Exception: | ||
logging.warning('Failed to convert prom url: %s to robusta url', prom_url, exc_info=True) | ||
return prom_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.