Adding alerts with grafonnet-lib

I’m setting up some dashboards in code using grafonnet-lib, but I’m not able to add Alerts. Currently running Grafana 6.3.5. Below is a snippet of my dashboard:

graph.new(
  title='Percentage Difference',
  span=6,
  format='percent',
  min='0',
  max='100',
  legend_show=false,
  datasource=datasource,
)
.addTarget(
  sql.target(
    rawSql='someRawSql',
    datasource=datasource,
  )
)
.addAlert(
  new.alert(
  )
),
.addAlert(
      'Testing alerts',
      executionErrorState='alerting',
      frequency='1h',
      handler=1,
      message='Testing alerts in code',
      noDataState='alerting',
      notifications=[],
    )
    .addCondition(
      alert.new(
        evaluatorParams=[1],
        evaluatorType='gt',
        operatorType='and',
        queryRefId='A',
        queryTimeEnd='now',
        queryTimeStart='24h',
        # reducerParams=[],
        # reducerType='avg',
      )
    )

Without the evaluatorParams the dashboard will fail to update without and error message

Hi all, I keep seeing Unknown variable: alert when trying to add this.

What is the exact local ... command I need to add?

local alertCondition = grafana.alertCondition; stil gives me the error.

Thanks in advance!

Found the typo in the above code example.

replace alert with alertCondition.

  alertCondition.new(
    evaluatorParams=[1],
    evaluatorType='gt',
    operatorType='and',
    queryRefId='A',
    queryTimeEnd='now',
    queryTimeStart='24h',
    # reducerParams=[],
    # reducerType='avg',
  )
)```