Frameworks
Python
Modal

Modal

Modal is a serverless platform that allows you to run Python functions in the cloud. IUDEX can be easily integrated into your Modal functions to provide monitoring, alerting, and logging capabilities

Install the Python client

pip install iudex

Create a write-only API key 🔑

Click settings in the top left corner of the IUDEX dashboard and create a write-only API key.

Create a write-only API key

Add IUDEX into your app 🚀

Modal only loads packages after running a particular serverless function. We recommend following their suggestions for using packages.

For example, to instrument a specific function:

@app.function(image=image)
def my_modal_function(x):
    from iudex import instrument
    instrument(
        service_name="YOUR_SERVICE_NAME", # highly encouraged
        env="prod", # dev, local, etc
        iudex_api_key="WRITE_ONLY_IUDEX_KEY", # only ever commit your WRITE ONLY key
    )
    # ^ Must run at the top of your Modal function

Set up Slack alerts 📣

Click the Slack logo in the top right of the dashboard and follow the prompts.

Slack integration button

Note: you must have admin permissions to add apps to your workspace.

Create a log 🪵

Add code to emit a log somewhere in your app. You can use print or Python’s logging module.

@app.function(image=image)
def my_modal_function(x):
    from iudex import instrument
    instrument(
        service_name="YOUR_SERVICE_NAME", # highly encouraged
        env="prod", # dev, local, etc
        iudex_api_key="WRITE_ONLY_IUDEX_KEY", # only ever commit your WRITE ONLY key
    )
    # ^ Must run at the top of your Modal function
    import logging
    logger = logging.getLogger(__name__)
    # Add this in your Modal function
    logger.info("Hello IUDEX!", extra={"iudex.slack_channel_id": "YOUR_SLACK_CHANNEL_ID"})

(In Slack, open the channel and click its name in the top left, then find its ID at the bottom of the dialog.)

Then simply run your modal function as usual to emit the log.

Verify 🧐

You should see the log in Slack and in your IUDEX dashboard log view.

Slack message

Log in IUDEX

Go in-depth 👉

Check out more in-depth guides on how to get the most out of IUDEX for your stack.