From aebe9504e11e03471798cdeebabd10de7b8e3728 Mon Sep 17 00:00:00 2001 From: Brian Hensley <48165493+brnhensley@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:13:02 -0800 Subject: [PATCH 1/2] chore: code in backticks --- .../bring-your-own/getting-started-byo.mdx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/content/docs/mlops/bring-your-own/getting-started-byo.mdx b/src/content/docs/mlops/bring-your-own/getting-started-byo.mdx index b45fbf5df5e..457df399399 100644 --- a/src/content/docs/mlops/bring-your-own/getting-started-byo.mdx +++ b/src/content/docs/mlops/bring-your-own/getting-started-byo.mdx @@ -92,14 +92,14 @@ We created these notebooks in Google colab so you can try them out: ## EU Account Users [#EU-account-users] -If you are using an EU account, send it as a parameter at the MLPerformanceMonitoring call if your environment variable is not set: +If you are using an EU account, send it as a parameter at the `MLPerformanceMonitoring` call if your environment variable is not set: -* `EVENT_CLIENT_HOST and METRIC_CLIENT_HOST` - * US region account (default) - - * `EVENT_CLIENT_HOST`: insights-collector.newrelic.com - * `METRIC_CLIENT_HOST`: metric-api.newrelic.com - * EU region account - - * `EVENT_CLIENT_HOST`: insights-collector.eu01.nr-data.net - * `METRIC_CLIENT_HOST`: metric-api.eu.newrelic.com/metric/v1 +* `EVENT_CLIENT_HOST` and `METRIC_CLIENT_HOST` + * US region account (default): + * `EVENT_CLIENT_HOST: insights-collector.newrelic.com` + * `METRIC_CLIENT_HOST: metric-api.newrelic.com` + * EU region account: + * `EVENT_CLIENT_HOST: insights-collector.eu01.nr-data.net` + * `METRIC_CLIENT_HOST: metric-api.eu.newrelic.com/metric/v1` -It can also be sent as parameters at the MLPerformanceMonitoring call. +It can also be sent as parameters at the `MLPerformanceMonitoring` call. From dd59ddedd601147326e10cd15f82382ba4b1daa9 Mon Sep 17 00:00:00 2001 From: Brian Hensley <48165493+brnhensley@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:21:36 -0800 Subject: [PATCH 2/2] fix: format code blocks --- .../datarobot-mlops-integration.mdx | 371 +++++++++--------- 1 file changed, 186 insertions(+), 185 deletions(-) diff --git a/src/content/docs/mlops/integrations/datarobot-mlops-integration.mdx b/src/content/docs/mlops/integrations/datarobot-mlops-integration.mdx index 22ab21fcce1..618e2ce2b94 100644 --- a/src/content/docs/mlops/integrations/datarobot-mlops-integration.mdx +++ b/src/content/docs/mlops/integrations/datarobot-mlops-integration.mdx @@ -38,75 +38,75 @@ Start monitoring your Datarobot event flows with New Relic. 2. **Create a dashboard:** Go to **[one.newrelic.com > All capabilities](https://one.newrelic.com/all-capabilities) > Dashboards**, then click the **Import dashboards** button. Copy and paste the JSON code into the **Paste your JSON field code**. -Update the YOUR_ACCOUNT_ID values with your account ID. +Update the `YOUR_ACCOUNT_ID` values with your account ID. ```json { -"name": "Datarobot Dashboard for Default Metrics", -"description": null, -"permissions": "PUBLIC_READ_WRITE", -"pages": [ -{ -"name": "Datarobot Dashboard for Default Metrics", -"description": null, -"widgets": [ -{ - "visualization": { - "id": "viz.line" - }, - "layout": { - "column": 1, - "row": 1, - "height": 3, - "width": 4 - }, - "title": "Runtime Duration by Algorithm", - "rawConfiguration": { - "legend": { - "enabled": true - }, - "nrqlQueries": [ - { - "accountId": YOUR_ACCOUNT_ID, - "query": "SELECT average(algorithmia.duration_milliseconds) FROM Metric TIMESERIES FACET `algorithm_name` LIMIT 10 SINCE 1800 seconds ago" - } - ], - "yAxisLeft": { - "zero": true - } - }, - "linkedEntityGuids": null -}, -{ - "visualization": { - "id": "viz.line" - }, - "layout": { - "column": 5, - "row": 1, - "height": 3, - "width": 4 - }, - "title": "Throughput by Algorithm", - "rawConfiguration": { - "legend": { - "enabled": true - }, - "nrqlQueries": [ - { - "accountId": YOUR_ACCOUNT_ID, - "query": "SELECT count(algorithmia.duration_milliseconds) FROM Metric TIMESERIES FACET `algorithm_name` LIMIT 10 SINCE 1800 seconds ago" - } - ], - "yAxisLeft": { - "zero": true + "name": "Datarobot Dashboard for Default Metrics", + "description": null, + "permissions": "PUBLIC_READ_WRITE", + "pages": [ + { + "name": "Datarobot Dashboard for Default Metrics", + "description": null, + "widgets": [ + { + "visualization": { + "id": "viz.line" + }, + "layout": { + "column": 1, + "row": 1, + "height": 3, + "width": 4 + }, + "title": "Runtime Duration by Algorithm", + "rawConfiguration": { + "legend": { + "enabled": true + }, + "nrqlQueries": [ + { + "accountId": YOUR_ACCOUNT_ID, + "query": "SELECT average(algorithmia.duration_milliseconds) FROM Metric TIMESERIES FACET `algorithm_name` LIMIT 10 SINCE 1800 seconds ago" + } + ], + "yAxisLeft": { + "zero": true + } + }, + "linkedEntityGuids": null + }, + { + "visualization": { + "id": "viz.line" + }, + "layout": { + "column": 5, + "row": 1, + "height": 3, + "width": 4 + }, + "title": "Throughput by Algorithm", + "rawConfiguration": { + "legend": { + "enabled": true + }, + "nrqlQueries": [ + { + "accountId": YOUR_ACCOUNT_ID, + "query": "SELECT count(algorithmia.duration_milliseconds) FROM Metric TIMESERIES FACET `algorithm_name` LIMIT 10 SINCE 1800 seconds ago" + } + ], + "yAxisLeft": { + "zero": true + } + }, + "linkedEntityGuids": null + } + ] } - }, - "linkedEntityGuids": null -} -] -} -] + ] } ``` @@ -115,55 +115,56 @@ Update the YOUR_ACCOUNT_ID values with your account ID. 4. **Create the New Relic connector algorithm:** Use Python 3.8 to create a connector algorithm. If you're new to writing code to generate algorithms, see [Datarobot's getting started guide](https://algorithmia.com/developers/algorithm-development/your-first-algo). ```python - import Datarobot - import json - from datetime import datetime - from newrelic_telemetry_sdk import GaugeMetric, MetricClient - - client = Datarobot.client() - metric_client = MetricClient(os.environ["newrelic_api_key"]) - - - def convert_str_timestamp_to_epoch(str_time): +import Datarobot +import json +from datetime import datetime +from newrelic_telemetry_sdk import GaugeMetric, MetricClient + +client = Datarobot.client() +metric_client = MetricClient(os.environ["newrelic_api_key"]) + + +def convert_str_timestamp_to_epoch(str_time): obj_time = datetime.strptime(str_time, "%Y-%m-%dT%H:%M:%S.%f") return int(obj_time.timestamp() * 1000) - - def get_operational_metrics(payload): + + +def get_operational_metrics(payload): ALGORITHM_TAGS = { - "algorithm_version", - "request_id", - "time", - "algorithm_name", - "session_id", - "algorithm_owner" - } - inference_metrics = { - key: payload[key] for key in payload.keys() ^ ALGORITHM_TAGS + "algorithm_version", + "request_id", + "time", + "algorithm_name", + "session_id", + "algorithm_owner", } + inference_metrics = {key: payload[key] for key in payload.keys() ^ ALGORITHM_TAGS} return inference_metrics - - def send_to_newrelic(inference_metrics, insights_payload): + + +def send_to_newrelic(inference_metrics, insights_payload): newrelic_metrics = [] for key, value in inference_metrics.items(): - name = "algorithmia." + key - epoch_time = convert_str_timestamp_to_epoch(insights_payload["time"]) - tags = { - "algorithm_name": insights_payload["algorithm_name"], - "algorithm_version": insights_payload["algorithm_version"], - "algorithm_owner": insights_payload["algorithm_owner"], - "request_id": insights_payload["request_id"], - "session_id": insights_payload["session_id"], - } - - newrelic_metrics.append(GaugeMetric( - name=name, value=value, tags=tags, end_time_ms=epoch_time - )) - - response = metric_client.send_batch(newrelic_metrics) - response.raise_for_status() - - - def apply(input): + name = "algorithmia." + key + epoch_time = convert_str_timestamp_to_epoch(insights_payload["time"]) + tags = { + "algorithm_name": insights_payload["algorithm_name"], + "algorithm_version": insights_payload["algorithm_version"], + "algorithm_owner": insights_payload["algorithm_owner"], + "request_id": insights_payload["request_id"], + "session_id": insights_payload["session_id"], + } + + +newrelic_metrics.append( + GaugeMetric(name=name, value=value, tags=tags, end_time_ms=epoch_time) +) + +response = metric_client.send_batch(newrelic_metrics) +response.raise_for_status() + + +def apply(input): insights_payload = input inference_metrics = get_operational_metrics(insights_payload) send_to_newrelic(inference_metrics, insights_payload) @@ -173,23 +174,23 @@ Update the YOUR_ACCOUNT_ID values with your account ID. Include these dependencies: ```python - algorithmia>=1.0.0,<2.0 - newrelic_telemetry_sdk==0.4.2 +algorithmia>=1.0.0,<2.0 +newrelic_telemetry_sdk==0.4.2 ``` Once your algorithm build finishes, you can test it with this sample payload to make sure it runs successfully. Your output should look something like this. -``` - { - "risk_score": 0.2, - "duration_milliseconds": 8, - "algorithm_version": "1.0.6", - "session_id": "rses-f28bb94a-5556-4aeb-a6d2-89493626bf4f", - "time": "2021-02-20T00:21:54.867231", - "algorithm_name": "credit_card_approval", - "request_id": "req-9f5345b4-a1cd-431c-a43a-bd2a06f4a6f4", - "algorithm_owner": "asli" - } +```json +{ + "risk_score": 0.2, + "duration_milliseconds": 8, + "algorithm_version": "1.0.6", + "session_id": "rses-f28bb94a-5556-4aeb-a6d2-89493626bf4f", + "time": "2021-02-20T00:21:54.867231", + "algorithm_name": "credit_card_approval", + "request_id": "req-9f5345b4-a1cd-431c-a43a-bd2a06f4a6f4", + "algorithm_owner": "asli" +} ``` 5. **Configure with your API key:** Add your New Relic API key to the [Datarobot secret store](https://algorithmia.com/developers/platform/algorithm-secrets). @@ -206,75 +207,75 @@ Follow these steps to get the most of observing your machine-learning data in Ne 2. **Create a dashboard:** Go to **[one.newrelic.com > All capabilities](https://one.newrelic.com/all-capabilities) > Dashboards**, then click the **Import dashboards** button. Copy and paste the JSON code into the **Paste your JSON field code**. -Update the YOUR_ACCOUNT_ID values with your account ID. +Update the `YOUR_ACCOUNT_ID` values with your account ID. ```json { -"name": "Datarobot Dashboard for Default Metrics", -"description": null, -"permissions": "PUBLIC_READ_WRITE", -"pages": [ -{ -"name": "Datarobot Dashboard for Default Metrics", -"description": null, -"widgets": [ -{ - "visualization": { - "id": "viz.line" - }, - "layout": { - "column": 1, - "row": 1, - "height": 3, - "width": 4 - }, - "title": "Runtime Duration by Algorithm", - "rawConfiguration": { - "legend": { - "enabled": true - }, - "nrqlQueries": [ - { - "accountId": YOUR_ACCOUNT_ID, - "query": "SELECT average(algorithmia.duration_milliseconds) FROM Metric TIMESERIES FACET `algorithm_name` LIMIT 10 SINCE 1800 seconds ago" - } - ], - "yAxisLeft": { - "zero": true - } - }, - "linkedEntityGuids": null -}, -{ - "visualization": { - "id": "viz.line" - }, - "layout": { - "column": 5, - "row": 1, - "height": 3, - "width": 4 - }, - "title": "Throughput by Algorithm", - "rawConfiguration": { - "legend": { - "enabled": true - }, - "nrqlQueries": [ - { - "accountId": YOUR_ACCOUNT_ID, - "query": "SELECT count(algorithmia.duration_milliseconds) FROM Metric TIMESERIES FACET `algorithm_name` LIMIT 10 SINCE 1800 seconds ago" - } - ], - "yAxisLeft": { - "zero": true + "name": "Datarobot Dashboard for Default Metrics", + "description": null, + "permissions": "PUBLIC_READ_WRITE", + "pages": [ + { + "name": "Datarobot Dashboard for Default Metrics", + "description": null, + "widgets": [ + { + "visualization": { + "id": "viz.line" + }, + "layout": { + "column": 1, + "row": 1, + "height": 3, + "width": 4 + }, + "title": "Runtime Duration by Algorithm", + "rawConfiguration": { + "legend": { + "enabled": true + }, + "nrqlQueries": [ + { + "accountId": YOUR_ACCOUNT_ID, + "query": "SELECT average(algorithmia.duration_milliseconds) FROM Metric TIMESERIES FACET `algorithm_name` LIMIT 10 SINCE 1800 seconds ago" + } + ], + "yAxisLeft": { + "zero": true + } + }, + "linkedEntityGuids": null + }, + { + "visualization": { + "id": "viz.line" + }, + "layout": { + "column": 5, + "row": 1, + "height": 3, + "width": 4 + }, + "title": "Throughput by Algorithm", + "rawConfiguration": { + "legend": { + "enabled": true + }, + "nrqlQueries": [ + { + "accountId": YOUR_ACCOUNT_ID, + "query": "SELECT count(algorithmia.duration_milliseconds) FROM Metric TIMESERIES FACET `algorithm_name` LIMIT 10 SINCE 1800 seconds ago" + } + ], + "yAxisLeft": { + "zero": true + } + }, + "linkedEntityGuids": null + } + ] } - }, - "linkedEntityGuids": null -} -] -} -] + ] } ```