Prometheus alert report from promQL to influxql

I have the follow promQL query - topk(5,sum by(alertname) (changes(ALERTS_FOR_STATE[7d]))) != 0

where basically it is counting the number of alerts in the past 7 days grouped by alertname.

I was wondering if anyone managed to change the above to Influxdb query.

from(bucket: “prometheus_alerts”)

|> range(start: -6h)

|> filter(fn: (r) => r[“alertstate”] == “firing” and r[“severity”] == “critical”)

|> group()

|> keep(columns: [“alertname”])

|> unique(column: “alertname”)

|> count(column: “alertname”)

I tried the above but i’m only getting the count of different alertnames and it does not allow me to add multiple columns.