Data provider events not being saved

I’m working on a Forge app with a data provider which will ingest incidents and alerts from New Relic into Compass.

I have followed the tutorials and reviewed the example code in the sample Statuspage repo.

I can’t see any errors or any obvious problems, but when adding a New Relic link, I don’t have any incident events recorded in my Compass component. For now I’m using a hard-coded DataProviderIncidentEvent object just to get everything all wired up correctly. Code details and behaviour as follows.

Snippet from my data provider function:

const response = new DataProviderResponse(nrLink.entityGuid, {
    eventTypes: [DataProviderEventTypes.INCIDENTS, DataProviderEventTypes.ALERTS],
    builtInMetricDefinitions: [ BuiltinMetricDefinitions.AVAILABILITY_28D,
      BuiltinMetricDefinitions.CHANGE_FAILURE_RATE_28D,
      BuiltinMetricDefinitions.INCIDENT_COUNT_28D,
      BuiltinMetricDefinitions.MTTR_LAST_10,
      BuiltinMetricDefinitions.RELIABILITY_28D
     ]
  });

  const testIncident = {
    displayName: 'Test Incident',
    description: 'Hard coded incident',
    lastUpdated: 1705276975141,
    updateSequenceNumber: 1702766907438,
    url: 'https://onenr.io/foo',
    id: '3564ffe9-9f6e-460d-8800-3583b2fbae67',
    state: CompassIncidentEventState.Resolved,
    severity: {
      label: 'MEDIUM',
      level: CompassIncidentEventSeverityLevel.Three,
    },
    startTime: 1705276255051,
    endTime: 1705276975141,
  };
  
  console.log('Adding test incident event', JSON.stringify(testIncident)); // TODO: update to add real incidents array
  response.addIncidents([ testIncident ]);

  const responsePayload = response.build();
  console.log('Response payload check', responsePayload, responsePayload.events.incidents);
  return responsePayload;

If I add a link to a New Relic dashboard, I can see the following:

  • Link is decorated with the “data connection” status and shows it’s configured to send incidents and alerts to the activity feed
  • Appropriate metric panels have been added to the Component overview
  • Log outputs show the expected log lines and no errors, the response payload definitely includes the test incident object in an array
  • Data provider callback function is not reporting an error

However, I cannot see:

  • Test Incident doesn’t appear in the Activity feed
  • I don’t see any record of the event via GraphQL query, either

Maybe I’m missing something with the correct format of the DataProviderIncidentEvent? I have double checked that I’ve copied this correctly from the sample app and checked the type definition from the forge-graphql package and can’t spot anything glaringly wrong.

Any help would be greatly appreciated!

1 Like

Having had a second look at the code with fresh eyes, I suspect my issue might be with the date field formats. It looks like this might need to be a string in RFC 3339 format, not an int / Unix time. I’ll update my tests and report back.

It would be really good if there was some validation possible so that events sent through in the data provider response didn’t just silently fail. Some clearer documentation would also help! The documentation for the DataProviderIncidentEvent type alias is currently a blank page.

OK, I think I have confirmed my theory - the following literal values have successfully created an incident event for me:

  let incidents = [{
    displayName: 'Test Incident',
    description: 'Hard coded incident',
    lastUpdated: '2024-01-17T02:49:54.994Z',
    updateSequenceNumber: (new Date()).getTime(),
    url: 'https://onenr.io/foo',
    id: '3564ffe9-9f6e-460d-8800-3583b2fbae67',
    state: CompassIncidentEventState.Resolved,
    severity: {
      label: 'MEDIUM',
      level: CompassIncidentEventSeverityLevel.Three,
    },
    startTime: '2024-01-17T02:39:55.242Z',
    endTime: '2024-01-17T02:49:54.994Z',
  }];

Just throwing that out there for anyone else running into the same issue with correct property formats.

1 Like