Skip to content

want an alert list endpoint in the public API #11005

Closed

Description

@hawkw

Currently, the only way to view alerts in the public API is to list the alerts that were dispatched to an alert receiver. This means that there is no way to consume alerts without first creating a receiver, and alerts that a receiver is not subscribed to cannot be accessed. As we use alerts for more things, it will become desirable to be able to list alerts without going through alert receivers. For example, we probably want to have a page in the web console that shows a timeline of all alerts (regardless of whether a receiver is subscribed to them) which the API does not currently let us do.

Therefore, we should add an API for listing alerts. It should probably be ordered by the alert's timestamp and paginated by timestamp and UUID (to ensure that we can uniquely identify the alert when paginating), similar to the audit log. It should also be possible to filter the alert list based on a set of alert classes or alert class globs, and a start/end time range. Luckily, there's already a database query for listing alerts that does all of this, it's just currently only used for omdb commands. It shouldn't be too difficult to wire this into the external API.

Activity

  1. added
    nexus
    on Aug 5, 2026
  2. added theissue type on Aug 5, 2026
  3. added
    fault-management
    api
    on Aug 5, 2026
  4. added this to the 23 milestone on Aug 10, 2026
  5. hawkw commented on Aug 11, 2026

    @hawkw
    MemberAuthor

    Hm, okay, so one big open question here is how to handle alert class versioning in the API. Alerts have their own notion of versioning per alert class, which is necessary when delivering alerts as webhooks. The "easy way out" would be to just add an Alert message for the alert API like this:

    #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
    pub struct Alert {
        #[serde(flatten)]
        pub identity: AssetIdentityMetadata,
        pub class: String,
        pub version: u32,
        pub payload: serde_json::Value,
    }

    where the alert class and alert payload version are just a string and integer, and the payload is an arbitrary pile of JSON, and the caller is responsible for figuring out the versioning.

    Alternatively, we could try and have a thing where the alert is instead represented like

    #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
    pub struct Alert {
        #[serde(flatten)]
        pub identity: AssetIdentityMetadata,
        pub payload: AlertPayload,
    }
    
    #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
    #[serde(tag = "class")]
    pub enum AlertPayload {
        #[serde(rename = "hardware.power_shelf.psu.insert")]
        PsuInserted(PsuInsertedAlert),
        // ...
    }
    
    #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
    #[serde(tag = "version", content = "payload")]
    pub enum PsuInsertedAlert {
        #[serde(rename = "0")]
        V0(PsuInsertedV0),
        // ...
    }
    
    // ...

    The big advantage of this is that it lets us include the alert classes and payloads in the OpenAPI schema, which I think is a Good Thing. However, it also means we're duplicating the alert class string in a third place (which I dislike), and adding a new version of an alert class will require duplicating all this stuff into a new API version (which is kinda just how that system works in the first place). I think the duplication of alert class strings could maybe Someday be resolved with a macro or something, but...hmm.

  6. hawkw commented on Aug 11, 2026

    @hawkw
    MemberAuthor

    Ugh. A new problem has appeared: openapi-lint really does not like the dotted alert class strings as enum variant identifiers:

         Failure nexus (versioned v2026081100.0.0 (added locally)): Oxide Region API
           error: Generated OpenAPI document for API "nexus" version 2026081100.0.0 is not valid: OpenAPI document validation failed:
                  An enumerated string contains a value 'hardware.power_shelf.psu.insert' that is neither snake_case nor SCREAMING_SNAKE_CASE:
                  Schema {
                      schema_data: SchemaData {
                          nullable: false,
                          read_only: false,
                          write_only: false,
                          deprecated: false,
                          external_docs: None,
                          example: None,
                          title: None,
                          description: None,
                          discriminator: None,
                          default: None,
                          extensions: {},
                      },
                      schema_kind: Type(
                          String(
                              StringType {
                                  format: Empty,
                                  pattern: None,
                                  enumeration: [
                                      Some(
                                          "hardware.power_shelf.psu.insert",
                                      ),
                                  ],
                                  min_length: None,
                                  max_length: None,
                              },
                          ),
                      ),
                  }
                  Add #[serde(rename = "hardware_power_shelf_psu_insert")] to the variant or #[serde(rename_all = "snake_case")] to the enum.
                  For more info see https://github.com/oxidecomputer/openapi-lint#naming
                  An enumerated string contains a value 'hardware.power_shelf.psu.remove' that is neither snake_case nor SCREAMING_SNAKE_CASE:
                  Schema {
                      schema_data: SchemaData {
                          nullable: false,
                          read_only: false,
                          write_only: false,
                          deprecated: false,
                          external_docs: None,
                          example: None,
                          title: None,
                          description: None,
                          discriminator: None,
                          default: None,
                          extensions: {},
                      },
                      schema_kind: Type(
                          String(
                              StringType {
                                  format: Empty,
                                  pattern: None,
                                  enumeration: [
                                      Some(
                                          "hardware.power_shelf.psu.remove",
                                      ),
                                  ],
                                  min_length: None,
                                  max_length: None,
                              },
                          ),
                      ),
                  }
                  Add #[serde(rename = "hardware_power_shelf_psu_remove")] to the variant or #[serde(rename_all = "snake_case")] to the enum.
                  For more info see https://github.com/oxidecomputer/openapi-lint#naming
    

    I'm somewhat displeased about this, because I think it's important to use the same class IDs in the alert_list API as what we use when sending the alerts, especially because that's how we glob them --- it would be quite surprising for a user if they requested an alert list filtered with a glob like hardware.power_shelf.psu.** and received a list with entries that described themselves as hardware_power_shelf_psu_remove. I think we shall need to handle this either by adding a way to ignore a specific API in openapi-lint,1 or make its linting for "snake case" names a little more permissive so hat it also permits other characters in the enum variant as long as the capitalization is correct. I'll see what @ahl thinks about this.

    Footnotes

    1. Which seems a bit annoying to do, as it would require adding a config file or something to openapi-lint and specifying the names of particular schemas in that file. We can't just stick an #[ignore] attribute on the Rust source code, since openapi-lint doesn't actually operate on the source code. ↩

  7. ahl commented on Aug 11, 2026

    @ahl
    Contributor

    2 comments ago, you proposed two alternatives: "here's some json; could be whatever" and "here's a meticulous schema of all events we know about right now". Certainly, we do need to articulate the schema for these things rigorously, but I think it may be the case that the public API has slightly different stability characteristics than the schema for these events. More concretely, I could imagine wanting to add new events (or new versions of similar events) without necessarily revving the API. Relatedly, we may want to encourage consumers of these APIs to accommodate event types and payloads that they don't know about a priori. To me, this argues for the "bag-o-json" approach for the actual API, and to document the schemas for known events in some alternate way (e.g. via JSON Schema) and some additional documentation generation.

    Having a less-structured API here also seems to be more expedient--probably the right approach until we understand who is building consumers of these events and how they want to build them.

  8. hawkw commented on Aug 11, 2026

    @hawkw
    MemberAuthor

    Yeah, after talking through it with Adam a bit, I've come around to the idea that we probably don't want strict schemas for the alerts to be communicated through the OpenAPI spec, and that the JSON schemas should be expressed out of band. This makes sense given that alerts are versioned separately from the rest of the API (clients must be prepared to handle older alert payload versions if they were generated on an older control plane). This has the nice side effect of making the alert list API much easier to implement, so it was an easy sell. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    apifault-managementnexus

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions