1. Packages
  2. Logfire
  3. API Docs
  4. Alert
Viewing docs for Logfire v0.1.9
published on Wednesday, Apr 8, 2026 by Pydantic
logfire logo
Viewing docs for Logfire v0.1.9
published on Wednesday, Apr 8, 2026 by Pydantic

    Manages a Logfire alert.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as logfire from "@pydantic/pulumi-logfire";
    
    const exampleProject = new logfire.Project("exampleProject", {});
    const exampleChannel = new logfire.Channel("exampleChannel", {config: [{
        type: "webhook",
        format: "auto",
        url: "https://example.com/logfire-webhook",
    }]});
    const exampleAlert = new logfire.Alert("exampleAlert", {
        projectId: exampleProject.id,
        description: "Alert on exception spans",
        query: `select
      service_name,
      trace_id,
      otel_status_message as exception_message
    from records
    where level = 'error'
    order by start_timestamp desc
    `,
        timeWindow: "1h",
        frequency: "15m",
        channelIds: [exampleChannel.id],
        notifyWhen: "has_matches",
        active: true,
    });
    
    import pulumi
    import pulumi_logfire as logfire
    
    example_project = logfire.Project("exampleProject")
    example_channel = logfire.Channel("exampleChannel", config=[{
        "type": "webhook",
        "format": "auto",
        "url": "https://example.com/logfire-webhook",
    }])
    example_alert = logfire.Alert("exampleAlert",
        project_id=example_project.id,
        description="Alert on exception spans",
        query="""select
      service_name,
      trace_id,
      otel_status_message as exception_message
    from records
    where level = 'error'
    order by start_timestamp desc
    """,
        time_window="1h",
        frequency="15m",
        channel_ids=[example_channel.id],
        notify_when="has_matches",
        active=True)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pydantic/pulumi-logfire/sdk/go/logfire"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleProject, err := logfire.NewProject(ctx, "exampleProject", nil)
    		if err != nil {
    			return err
    		}
    		exampleChannel, err := logfire.NewChannel(ctx, "exampleChannel", &logfire.ChannelArgs{
    			Config: logfire.ChannelConfigArgs{
    				map[string]interface{}{
    					"type":   "webhook",
    					"format": "auto",
    					"url":    "https://example.com/logfire-webhook",
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = logfire.NewAlert(ctx, "exampleAlert", &logfire.AlertArgs{
    			ProjectId:   exampleProject.ID(),
    			Description: pulumi.String("Alert on exception spans"),
    			Query: pulumi.String(`select
      service_name,
      trace_id,
      otel_status_message as exception_message
    from records
    where level = 'error'
    order by start_timestamp desc
    `),
    			TimeWindow: pulumi.String("1h"),
    			Frequency:  pulumi.String("15m"),
    			ChannelIds: pulumi.StringArray{
    				exampleChannel.ID(),
    			},
    			NotifyWhen: pulumi.String("has_matches"),
    			Active:     pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Logfire = Pulumi.Logfire;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleProject = new Logfire.Project("exampleProject");
    
        var exampleChannel = new Logfire.Channel("exampleChannel", new()
        {
            Config = new[]
            {
                
                {
                    { "type", "webhook" },
                    { "format", "auto" },
                    { "url", "https://example.com/logfire-webhook" },
                },
            },
        });
    
        var exampleAlert = new Logfire.Alert("exampleAlert", new()
        {
            ProjectId = exampleProject.Id,
            Description = "Alert on exception spans",
            Query = @"select
      service_name,
      trace_id,
      otel_status_message as exception_message
    from records
    where level = 'error'
    order by start_timestamp desc
    ",
            TimeWindow = "1h",
            Frequency = "15m",
            ChannelIds = new[]
            {
                exampleChannel.Id,
            },
            NotifyWhen = "has_matches",
            Active = true,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.logfire.Project;
    import com.pulumi.logfire.Channel;
    import com.pulumi.logfire.ChannelArgs;
    import com.pulumi.logfire.Alert;
    import com.pulumi.logfire.AlertArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var exampleProject = new Project("exampleProject");
    
            var exampleChannel = new Channel("exampleChannel", ChannelArgs.builder()
                .config(ChannelConfigArgs.builder()
                    .type("webhook")
                    .format("auto")
                    .url("https://example.com/logfire-webhook")
                    .build())
                .build());
    
            var exampleAlert = new Alert("exampleAlert", AlertArgs.builder()
                .projectId(exampleProject.id())
                .description("Alert on exception spans")
                .query("""
    select
      service_name,
      trace_id,
      otel_status_message as exception_message
    from records
    where level = 'error'
    order by start_timestamp desc
                """)
                .timeWindow("1h")
                .frequency("15m")
                .channelIds(exampleChannel.id())
                .notifyWhen("has_matches")
                .active(true)
                .build());
    
        }
    }
    
    resources:
      exampleProject:
        type: logfire:Project
      exampleChannel:
        type: logfire:Channel
        properties:
          config:
            - type: webhook
              format: auto
              url: https://example.com/logfire-webhook
      exampleAlert:
        type: logfire:Alert
        properties:
          projectId: ${exampleProject.id}
          description: Alert on exception spans
          query: |
            select
              service_name,
              trace_id,
              otel_status_message as exception_message
            from records
            where level = 'error'
            order by start_timestamp desc
          timeWindow: 1h
          frequency: 15m
          channelIds:
            - ${exampleChannel.id}
          notifyWhen: has_matches
          active: true
    

    Create Alert Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new Alert(name: string, args: AlertArgs, opts?: CustomResourceOptions);
    @overload
    def Alert(resource_name: str,
              args: AlertArgs,
              opts: Optional[ResourceOptions] = None)
    
    @overload
    def Alert(resource_name: str,
              opts: Optional[ResourceOptions] = None,
              channel_ids: Optional[Sequence[str]] = None,
              frequency: Optional[str] = None,
              notify_when: Optional[str] = None,
              project_id: Optional[str] = None,
              query: Optional[str] = None,
              time_window: Optional[str] = None,
              active: Optional[bool] = None,
              description: Optional[str] = None,
              name: Optional[str] = None)
    func NewAlert(ctx *Context, name string, args AlertArgs, opts ...ResourceOption) (*Alert, error)
    public Alert(string name, AlertArgs args, CustomResourceOptions? opts = null)
    public Alert(String name, AlertArgs args)
    public Alert(String name, AlertArgs args, CustomResourceOptions options)
    
    type: logfire:Alert
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args AlertArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args AlertArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args AlertArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args AlertArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args AlertArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var alertResource = new Logfire.Index.Alert("alertResource", new()
    {
        ChannelIds = new[]
        {
            "string",
        },
        Frequency = "string",
        NotifyWhen = "string",
        ProjectId = "string",
        Query = "string",
        TimeWindow = "string",
        Active = false,
        Description = "string",
        Name = "string",
    });
    
    example, err := logfire.NewAlert(ctx, "alertResource", &logfire.AlertArgs{
    	ChannelIds: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Frequency:   pulumi.String("string"),
    	NotifyWhen:  pulumi.String("string"),
    	ProjectId:   pulumi.String("string"),
    	Query:       pulumi.String("string"),
    	TimeWindow:  pulumi.String("string"),
    	Active:      pulumi.Bool(false),
    	Description: pulumi.String("string"),
    	Name:        pulumi.String("string"),
    })
    
    var alertResource = new Alert("alertResource", AlertArgs.builder()
        .channelIds("string")
        .frequency("string")
        .notifyWhen("string")
        .projectId("string")
        .query("string")
        .timeWindow("string")
        .active(false)
        .description("string")
        .name("string")
        .build());
    
    alert_resource = logfire.Alert("alertResource",
        channel_ids=["string"],
        frequency="string",
        notify_when="string",
        project_id="string",
        query="string",
        time_window="string",
        active=False,
        description="string",
        name="string")
    
    const alertResource = new logfire.Alert("alertResource", {
        channelIds: ["string"],
        frequency: "string",
        notifyWhen: "string",
        projectId: "string",
        query: "string",
        timeWindow: "string",
        active: false,
        description: "string",
        name: "string",
    });
    
    type: logfire:Alert
    properties:
        active: false
        channelIds:
            - string
        description: string
        frequency: string
        name: string
        notifyWhen: string
        projectId: string
        query: string
        timeWindow: string
    

    Alert Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The Alert resource accepts the following input properties:

    ChannelIds List<string>
    Set of channel IDs to notify.
    Frequency string
    Evaluation frequency as Go duration.
    NotifyWhen string
    Notification rule. Must match API enum.
    ProjectId string
    Project ID (UUID) used for alert API paths.
    Query string
    SQL / query string used by the alert.
    TimeWindow string
    Lookback window as Go duration.
    Active bool
    Whether the alert is active (defaults to true on creation).
    Description string
    Alert description.
    Name string
    Alert name (unique per project).
    ChannelIds []string
    Set of channel IDs to notify.
    Frequency string
    Evaluation frequency as Go duration.
    NotifyWhen string
    Notification rule. Must match API enum.
    ProjectId string
    Project ID (UUID) used for alert API paths.
    Query string
    SQL / query string used by the alert.
    TimeWindow string
    Lookback window as Go duration.
    Active bool
    Whether the alert is active (defaults to true on creation).
    Description string
    Alert description.
    Name string
    Alert name (unique per project).
    channelIds List<String>
    Set of channel IDs to notify.
    frequency String
    Evaluation frequency as Go duration.
    notifyWhen String
    Notification rule. Must match API enum.
    projectId String
    Project ID (UUID) used for alert API paths.
    query String
    SQL / query string used by the alert.
    timeWindow String
    Lookback window as Go duration.
    active Boolean
    Whether the alert is active (defaults to true on creation).
    description String
    Alert description.
    name String
    Alert name (unique per project).
    channelIds string[]
    Set of channel IDs to notify.
    frequency string
    Evaluation frequency as Go duration.
    notifyWhen string
    Notification rule. Must match API enum.
    projectId string
    Project ID (UUID) used for alert API paths.
    query string
    SQL / query string used by the alert.
    timeWindow string
    Lookback window as Go duration.
    active boolean
    Whether the alert is active (defaults to true on creation).
    description string
    Alert description.
    name string
    Alert name (unique per project).
    channel_ids Sequence[str]
    Set of channel IDs to notify.
    frequency str
    Evaluation frequency as Go duration.
    notify_when str
    Notification rule. Must match API enum.
    project_id str
    Project ID (UUID) used for alert API paths.
    query str
    SQL / query string used by the alert.
    time_window str
    Lookback window as Go duration.
    active bool
    Whether the alert is active (defaults to true on creation).
    description str
    Alert description.
    name str
    Alert name (unique per project).
    channelIds List<String>
    Set of channel IDs to notify.
    frequency String
    Evaluation frequency as Go duration.
    notifyWhen String
    Notification rule. Must match API enum.
    projectId String
    Project ID (UUID) used for alert API paths.
    query String
    SQL / query string used by the alert.
    timeWindow String
    Lookback window as Go duration.
    active Boolean
    Whether the alert is active (defaults to true on creation).
    description String
    Alert description.
    name String
    Alert name (unique per project).

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Alert resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Watermark string
    Provider-managed watermark (lateness tolerance) sent to the API.
    Id string
    The provider-assigned unique ID for this managed resource.
    Watermark string
    Provider-managed watermark (lateness tolerance) sent to the API.
    id String
    The provider-assigned unique ID for this managed resource.
    watermark String
    Provider-managed watermark (lateness tolerance) sent to the API.
    id string
    The provider-assigned unique ID for this managed resource.
    watermark string
    Provider-managed watermark (lateness tolerance) sent to the API.
    id str
    The provider-assigned unique ID for this managed resource.
    watermark str
    Provider-managed watermark (lateness tolerance) sent to the API.
    id String
    The provider-assigned unique ID for this managed resource.
    watermark String
    Provider-managed watermark (lateness tolerance) sent to the API.

    Look up Existing Alert Resource

    Get an existing Alert resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: AlertState, opts?: CustomResourceOptions): Alert
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            active: Optional[bool] = None,
            channel_ids: Optional[Sequence[str]] = None,
            description: Optional[str] = None,
            frequency: Optional[str] = None,
            name: Optional[str] = None,
            notify_when: Optional[str] = None,
            project_id: Optional[str] = None,
            query: Optional[str] = None,
            time_window: Optional[str] = None,
            watermark: Optional[str] = None) -> Alert
    func GetAlert(ctx *Context, name string, id IDInput, state *AlertState, opts ...ResourceOption) (*Alert, error)
    public static Alert Get(string name, Input<string> id, AlertState? state, CustomResourceOptions? opts = null)
    public static Alert get(String name, Output<String> id, AlertState state, CustomResourceOptions options)
    resources:  _:    type: logfire:Alert    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Active bool
    Whether the alert is active (defaults to true on creation).
    ChannelIds List<string>
    Set of channel IDs to notify.
    Description string
    Alert description.
    Frequency string
    Evaluation frequency as Go duration.
    Name string
    Alert name (unique per project).
    NotifyWhen string
    Notification rule. Must match API enum.
    ProjectId string
    Project ID (UUID) used for alert API paths.
    Query string
    SQL / query string used by the alert.
    TimeWindow string
    Lookback window as Go duration.
    Watermark string
    Provider-managed watermark (lateness tolerance) sent to the API.
    Active bool
    Whether the alert is active (defaults to true on creation).
    ChannelIds []string
    Set of channel IDs to notify.
    Description string
    Alert description.
    Frequency string
    Evaluation frequency as Go duration.
    Name string
    Alert name (unique per project).
    NotifyWhen string
    Notification rule. Must match API enum.
    ProjectId string
    Project ID (UUID) used for alert API paths.
    Query string
    SQL / query string used by the alert.
    TimeWindow string
    Lookback window as Go duration.
    Watermark string
    Provider-managed watermark (lateness tolerance) sent to the API.
    active Boolean
    Whether the alert is active (defaults to true on creation).
    channelIds List<String>
    Set of channel IDs to notify.
    description String
    Alert description.
    frequency String
    Evaluation frequency as Go duration.
    name String
    Alert name (unique per project).
    notifyWhen String
    Notification rule. Must match API enum.
    projectId String
    Project ID (UUID) used for alert API paths.
    query String
    SQL / query string used by the alert.
    timeWindow String
    Lookback window as Go duration.
    watermark String
    Provider-managed watermark (lateness tolerance) sent to the API.
    active boolean
    Whether the alert is active (defaults to true on creation).
    channelIds string[]
    Set of channel IDs to notify.
    description string
    Alert description.
    frequency string
    Evaluation frequency as Go duration.
    name string
    Alert name (unique per project).
    notifyWhen string
    Notification rule. Must match API enum.
    projectId string
    Project ID (UUID) used for alert API paths.
    query string
    SQL / query string used by the alert.
    timeWindow string
    Lookback window as Go duration.
    watermark string
    Provider-managed watermark (lateness tolerance) sent to the API.
    active bool
    Whether the alert is active (defaults to true on creation).
    channel_ids Sequence[str]
    Set of channel IDs to notify.
    description str
    Alert description.
    frequency str
    Evaluation frequency as Go duration.
    name str
    Alert name (unique per project).
    notify_when str
    Notification rule. Must match API enum.
    project_id str
    Project ID (UUID) used for alert API paths.
    query str
    SQL / query string used by the alert.
    time_window str
    Lookback window as Go duration.
    watermark str
    Provider-managed watermark (lateness tolerance) sent to the API.
    active Boolean
    Whether the alert is active (defaults to true on creation).
    channelIds List<String>
    Set of channel IDs to notify.
    description String
    Alert description.
    frequency String
    Evaluation frequency as Go duration.
    name String
    Alert name (unique per project).
    notifyWhen String
    Notification rule. Must match API enum.
    projectId String
    Project ID (UUID) used for alert API paths.
    query String
    SQL / query string used by the alert.
    timeWindow String
    Lookback window as Go duration.
    watermark String
    Provider-managed watermark (lateness tolerance) sent to the API.

    Package Details

    Repository
    logfire pydantic/pulumi-logfire
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the logfire Terraform Provider.
    logfire logo
    Viewing docs for Logfire v0.1.9
    published on Wednesday, Apr 8, 2026 by Pydantic
      Try Pulumi Cloud free. Your team will thank you.