Skip to content

Commit

Permalink
Merge pull request #201 from axiomhq/add-summarize-query-example
Browse files Browse the repository at this point in the history
Add summarize query example
  • Loading branch information
SollyzDev authored Jun 12, 2024
2 parents 2f0ebae + 63474ee commit 4746e68
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/js/src/summarize-query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// This example shows querying a dataset with summarized results.
import { Axiom } from '@axiomhq/js';

const axiom = new Axiom({ token: process.env.AXIOM_TOKEN || '', orgId: process.env.AXIOM_ORG_ID || '' });

async function query() {
const aplQuery = `
['my-dataset']
| where foo == "bar"
and _time > datetime('2024-05-02')
and _time < datetime('2024-05-27')
| summarize cost = sum(value) by group_field
`;

try {
const res = await axiom.query(aplQuery);
console.log(JSON.stringify(res, null, 2));
} catch (error) {
console.error('ERROR:', error);
}
}

query();

0 comments on commit 4746e68

Please sign in to comment.