Cloud Dedicated documentation (#4903)
* base changes for influxdb cloud dedicated * removed unnecessary whitespace from dedicated homepage * influxctl reference documentation (#4855) * influxctl reference docs * fixed typo, added auth0 token life span * Apply suggestions from code review Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> * more updates to influxctl docs * update influxctl docs to address PR feedback --------- Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> * Add admin and manage databases sections to Cloud Dedicated (#4857) * add admin and manage databases sections * Apply suggestions from code review Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> * added missing page descriptions to admin docs --------- Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> * Add token management documentation to Cloud Dedicated documentation (#4861) * add manage tokens documentation to dedicated * Apply suggestions from code review Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> * update admin token docs to address PR feedback --------- Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> * Dedicated get started (#4878) * WIP dedicated get started content * fix(cst): infinite cardinality (#4851) * WIP cloud dedicated get started * feat(cloud-dedicated): WIP - write data to Cloud Dedicated * fix(cloud-dedicated): grammar. * feat(cloud-dedicated): WIP outline write methods, v1 API use * fix(cloud-dedicated): dupe name. * updated staging config, fixed dedicated page titles * updated dedicated setup doc * Cloud Dedicated primers v1 API: auth and write (#4865) * feat(cloud-dedicated): v1 API with Cloud Dedicated - Add /primers >> /api >> /v1 and /v2 - Move draft started in /write-data to /primers/api/v1 - Created code samples that still need testing - v1 authentication schemes. * fix(cloud-dedicated): list children pages * wip(cloud-dedicated): v1 primer intro * wip(cloud-dedicated): auth fixes. * feat(cloud-dedicated): v1 API primer - part of #4863, #4864 Still untested against CST: - v1 auth methods - v1 /write - Telegraf config - Precision - API sample code * Update content/influxdb/cloud-dedicated/primers/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/_index.md * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v2/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v2/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update layouts/shortcodes/api/cloud/v2-prefer.html Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update shared/text/api/cloud-dedicated/basic-auth.js Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> --------- Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Dedicated v1 write (#4873) * wip(v1): Revise v1 and add client library info. * feat(cloud-dedicated): primer v1 API auth and writes - Fixes for v1 auth and writes - Configuring node and python v1 client libraries for Cloud Dedicated. * fix(cloud-dedicated): v1 intros: - Fix redundant intro - Query intros * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> --------- Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Dedicated v2 write (#4875) * fix(cloud-dedicated): v1 API primer: - fix typo - fix description * wip(cloud-dedicated): v2 auth, write, Telegraf * feat(cloud-dedicated): v2 API primer (#4874) - v2 authentication - Write using /api/v2/write - Cleanup in v1 * Update content/influxdb/cloud-dedicated/primers/api/v2/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/primers/api/v1/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update shared/text/api/cloud-dedicated/token-auth-v2-write.sh Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * fix(cloud-dedicated): parameters for v1 and v2 writes - testing proves that org can't be empty Ongoing: - writes with v2 client library appear to work, but I can't find the measurement when I query. - v1 writes with curl respond with 404. --------- Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Add Python and Go write instructions to Cloud Dedicated get started (#4876) * added python and go write instructions to dedicated get started * Add get started query guide to dedicated (#4877) * Add get started query guide to dedicated * Apply suggestions from code review Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> --------- Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> * Apply suggestions from code review Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> * Apply suggestions from code review --------- Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> --------- Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> * Port reference content into dedicated (#4879) * ported line protocol and sql reference * port glossary to dedicated * fix(cloud-dedicated): cleanup (#4880) * fix(cloud-dedicated): v1 parameter values - Fixes parameter values in requests. - Based on inspection of the request (default port, content-type headers). - Still not working in CST. * fix(cloud-dedicated): cleanup auth description and list query tools. * fix(cloud-dedicated): cleanup auth examples: - remove boilerplate JS examples. Eventually replace with client lib examples. - fix incorrect URL - replace localhost with cloud2 host * fix(cloud-dedicated): replace placeholders * Add support for custom dedicated URLs (#4882) * add support for custom dedicated urls * Apply suggestions from code review Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> * removed unnecessary conditional in influxdb-urls.js --------- Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> * add information about flight sql support (#4894) * Update influxctl install and setup instructions (#4893) * updated influxctl install and setup instructions * added details to influxctl init page * Apply suggestions from code review Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> --------- Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> * Dedicated query data (#4895) * WIP port query data section to dedicated * updated database-name to iox-namespace-name * updated grafana instructions * update grafana install instructions * updated images and links * fixed broken links in query data section * fix(cloud-dedicated): get-started write (#4890) * fix(cloud-dedicated): package name typo * fix(cloud-dedicated): URL missing query * fix(cloud-dedicated): iox-namespace-name * fix(cloud-dedicated): use get-started database name * fix(cloud-dedicated): add auth-specific examples. * fix(cloud-dedicated): use Bearer for v2 example * fix(cloud-dedicated): add a note about token schemes and link to primer. * fix(cloud-dedicated): org no longer required by API, remove from curl example * fix(cloud-dedicated): use Bearer * fix(cloud-dedicated): wordsmithing * fix(cloud-dedicated): file name * fix(cloud-dedicated): Go client works without org * fix(cloud-dedicated): separate the commands for copy-pasting * fix(cloud-dedicated): v1 API token authentication * fix(cloud-dedicated): org parameter ignored, but needed in python clients * fix(cloud-dedicated): v1 API examples and params for /query (#4897) * fix(cloud-dedicated): minor word change (#4898) * New homepage and structural changes (#4899) * WIP first sweep of cloud-iox to cloud-serverless * WIP iox to serverless content updates * WIP iox to serverless updates in page templates and data files * WIP new homepage * chore(dedicated): copy best-practices from serverless * fix(serverless): missing shortcut * new homepage * fix(dedicated): token links in v1 API primer * chore(dedicated): write csv with Telegraf * fix(serverless): write CSV with Telegraf * updated homepage styles * updated deps, fix unclosed shortcodes, fix light css * fix product selector order * updated database naming restrictions, add resource delete confirmation * add cloud-ios to cloud-serverless redirect to edge.js * remove sh from allowed extentions * fix bug in redirect logic * add sections to product dropdown (#4900) * minor homepage css adjustment * fixed page titles * fixed more iox references in templates * Apply suggestions from code review Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> * Migrate 1.x data to dedicated (#4901) * fix(serverless): cleanup * chore(dedicated): Migrate 1.x data to dedicated - Minimal adaptation of IOx to Dedicated for now. - Use APIs for writing data (CLIs? pyinflux3 only writes CSV? Can't promote influxdb_iox for now) - Add 2.x CLI warning * fix(dedicated): URL typos * Update content/influxdb/cloud-dedicated/write-data/migrate-data/_index.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/write-data/migrate-data/migrate-1x-to-cloud-dedicated.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/write-data/migrate-data/migrate-1x-to-cloud-dedicated.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/write-data/migrate-data/migrate-1x-to-cloud-dedicated.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/write-data/migrate-data/migrate-1x-to-cloud-dedicated.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud-dedicated/write-data/migrate-data/migrate-1x-to-cloud-dedicated.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> --------- Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> --------- Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> * add step for requesting a cluster in dedicated setup * minor content fixes in best practices --------- Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com>pull/4904/head
parent
d05ef84959
commit
6223ef0ecd
|
@ -92,8 +92,6 @@ function updateTimestamps(newStartDate) {
|
||||||
$(updateBlockElWhitelist.join()).each(function() {
|
$(updateBlockElWhitelist.join()).each(function() {
|
||||||
var wrapper = $(this)[0]
|
var wrapper = $(this)[0]
|
||||||
|
|
||||||
console.log(wrapper)
|
|
||||||
|
|
||||||
times.forEach(function(x) {
|
times.forEach(function(x) {
|
||||||
oldDatePart = datePart(x.rfc3339.replace(/T.*$/, ""))
|
oldDatePart = datePart(x.rfc3339.replace(/T.*$/, ""))
|
||||||
newDatePart = datePart(x.rfc3339_new.replace(/T.*$/, ""))
|
newDatePart = datePart(x.rfc3339_new.replace(/T.*$/, ""))
|
||||||
|
@ -110,8 +108,6 @@ function updateTimestamps(newStartDate) {
|
||||||
$('span.get-started-timestamps').each(function() {
|
$('span.get-started-timestamps').each(function() {
|
||||||
var wrapper = $(this)[0]
|
var wrapper = $(this)[0]
|
||||||
|
|
||||||
console.log(wrapper)
|
|
||||||
|
|
||||||
times.forEach(function(x) {
|
times.forEach(function(x) {
|
||||||
oldDatePart = datePart(x.rfc3339.replace(/T.*$/, ""))
|
oldDatePart = datePart(x.rfc3339.replace(/T.*$/, ""))
|
||||||
newDatePart = datePart(x.rfc3339_new.replace(/T.*$/, ""))
|
newDatePart = datePart(x.rfc3339_new.replace(/T.*$/, ""))
|
||||||
|
|
|
@ -1,19 +1,23 @@
|
||||||
var placeholderUrls = {
|
var placeholderUrls = {
|
||||||
cloud: "https://cloud2.influxdata.com",
|
cloud: "https://cloud2.influxdata.com",
|
||||||
oss: "http://localhost:8086"
|
oss: "http://localhost:8086",
|
||||||
|
dedicated: "cluster-id.influxdb.io"
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultUrls = {
|
var defaultUrls = {
|
||||||
cloud: "https://us-west-2-1.aws.cloud2.influxdata.com",
|
cloud: "https://us-west-2-1.aws.cloud2.influxdata.com",
|
||||||
oss: "http://localhost:8086"
|
oss: "http://localhost:8086",
|
||||||
|
dedicated: "cluster-id.influxdb.io"
|
||||||
}
|
}
|
||||||
|
|
||||||
var elementSelector = ".article--content pre:not(.preserve)"
|
var elementSelector = ".article--content pre:not(.preserve)"
|
||||||
|
|
||||||
// Return the page context (cloud, oss/enterprise, other)
|
// Return the page context (cloud, oss/enterprise, other)
|
||||||
function context() {
|
function context() {
|
||||||
if (/\/influxdb\/cloud/.test(window.location.pathname)) {
|
if (/\/influxdb\/cloud(?:-iox)/.test(window.location.pathname)) {
|
||||||
return "cloud"
|
return "cloud"
|
||||||
|
} else if (/\/influxdb\/cloud-dedicated/.test(window.location.pathname)) {
|
||||||
|
return "dedicated"
|
||||||
} else if (/\/(enterprise_|influxdb).*\/v[1-2]\.[0-9]{1,2}\//.test(window.location.pathname)) {
|
} else if (/\/(enterprise_|influxdb).*\/v[1-2]\.[0-9]{1,2}\//.test(window.location.pathname)) {
|
||||||
return "oss/enterprise"
|
return "oss/enterprise"
|
||||||
} else {
|
} else {
|
||||||
|
@ -45,8 +49,10 @@ function setApiLibPreference(preference) {
|
||||||
//
|
//
|
||||||
// influxdb_oss_url
|
// influxdb_oss_url
|
||||||
// influxdb_cloud_url
|
// influxdb_cloud_url
|
||||||
|
// influxdb_dedicated_url
|
||||||
// influxdb_prev_oss_url
|
// influxdb_prev_oss_url
|
||||||
// influxdb_prev_cloud_url
|
// influxdb_prev_cloud_url
|
||||||
|
// influxdb_prev_dedicated_url
|
||||||
// influxdb_pref (cloud | oss)
|
// influxdb_pref (cloud | oss)
|
||||||
// influxdb_custom_url
|
// influxdb_custom_url
|
||||||
|
|
||||||
|
@ -69,6 +75,19 @@ function removeCustomUrl() {
|
||||||
Cookies.remove('influxdb_custom_url')
|
Cookies.remove('influxdb_custom_url')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store dedicated URL session cookie – influxdb_dedicated_url
|
||||||
|
// Used to populate the custom URL field
|
||||||
|
function storeDedicatedUrl(dedicatedUrl) {
|
||||||
|
Cookies.set('influxdb_dedicated_url', dedicatedUrl)
|
||||||
|
$('input#dedicated-url-field').val(dedicatedUrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove dedicated URL session cookie – influxdb_dedicated_url
|
||||||
|
// Used to clear the form when dedicated url input is left empty
|
||||||
|
function removeDedicatedUrl() {
|
||||||
|
Cookies.remove('influxdb_dedicated_url')
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////// InfluxDB URL utility functions ////////////////////////
|
//////////////////////// InfluxDB URL utility functions ////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -94,9 +113,11 @@ function addPreserve() {
|
||||||
function getUrls() {
|
function getUrls() {
|
||||||
var currentCloudUrl = Cookies.get('influxdb_cloud_url') || defaultUrls.cloud
|
var currentCloudUrl = Cookies.get('influxdb_cloud_url') || defaultUrls.cloud
|
||||||
var currentOSSUrl = Cookies.get('influxdb_oss_url') || defaultUrls.oss
|
var currentOSSUrl = Cookies.get('influxdb_oss_url') || defaultUrls.oss
|
||||||
|
var currentDedicatedUrl = Cookies.get('influxdb_dedicated_url') || defaultUrls.dedicated
|
||||||
var urls = {
|
var urls = {
|
||||||
cloud: currentCloudUrl,
|
cloud: currentCloudUrl,
|
||||||
oss: currentOSSUrl
|
oss: currentOSSUrl,
|
||||||
|
dedicated: currentDedicatedUrl
|
||||||
};
|
};
|
||||||
return urls;
|
return urls;
|
||||||
}
|
}
|
||||||
|
@ -107,9 +128,11 @@ function getUrls() {
|
||||||
function getPrevUrls() {
|
function getPrevUrls() {
|
||||||
var prevCloudUrl = Cookies.get('influxdb_prev_cloud_url') || defaultUrls.cloud
|
var prevCloudUrl = Cookies.get('influxdb_prev_cloud_url') || defaultUrls.cloud
|
||||||
var prevOSSUrl = Cookies.get('influxdb_prev_oss_url') || defaultUrls.oss
|
var prevOSSUrl = Cookies.get('influxdb_prev_oss_url') || defaultUrls.oss
|
||||||
|
var prevDedicatedUrl = Cookies.get('influxdb_prev_dedicated_url') || defaultUrls.dedicated
|
||||||
var prevUrls = {
|
var prevUrls = {
|
||||||
cloud: prevCloudUrl,
|
cloud: prevCloudUrl,
|
||||||
oss: prevOSSUrl
|
oss: prevOSSUrl,
|
||||||
|
dedicated: prevDedicatedUrl
|
||||||
};
|
};
|
||||||
return prevUrls;
|
return prevUrls;
|
||||||
}
|
}
|
||||||
|
@ -133,19 +156,21 @@ function updateUrls(prevUrls, newUrls) {
|
||||||
var preference = getPreference()
|
var preference = getPreference()
|
||||||
var prevUrlsParsed = {
|
var prevUrlsParsed = {
|
||||||
cloud: {},
|
cloud: {},
|
||||||
oss: {}
|
oss: {},
|
||||||
|
dedicated: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
var newUrlsParsed = {
|
var newUrlsParsed = {
|
||||||
cloud: {},
|
cloud: {},
|
||||||
oss: {}
|
oss: {},
|
||||||
|
dedicated: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.keys(prevUrls).forEach(function(k) {
|
Object.keys(prevUrls).forEach(function(k) {
|
||||||
try {
|
try {
|
||||||
prevUrlsParsed[k] = new URL(prevUrls[k])
|
prevUrlsParsed[k] = new URL(prevUrls[k])
|
||||||
} catch {
|
} catch {
|
||||||
prevUrlsParsed[k] = { host: prevUrls[k] }
|
prevUrlsParsed[k] = { origin: prevUrls[k], host: prevUrls[k] }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -153,7 +178,7 @@ function updateUrls(prevUrls, newUrls) {
|
||||||
try {
|
try {
|
||||||
newUrlsParsed[k] = new URL(newUrls[k])
|
newUrlsParsed[k] = new URL(newUrls[k])
|
||||||
} catch {
|
} catch {
|
||||||
newUrlsParsed[k] = { host: newUrls[k] }
|
newUrlsParsed[k] = { origin: newUrls[k], host: newUrls[k] }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -169,8 +194,12 @@ function updateUrls(prevUrls, newUrls) {
|
||||||
{ replace: prevUrlsParsed.cloud, with: newUrlsParsed.cloud },
|
{ replace: prevUrlsParsed.cloud, with: newUrlsParsed.cloud },
|
||||||
{ replace: prevUrlsParsed.oss, with: newUrlsParsed.oss },
|
{ replace: prevUrlsParsed.oss, with: newUrlsParsed.oss },
|
||||||
]
|
]
|
||||||
|
var dedicatedReplacements = [
|
||||||
|
{ replace: prevUrlsParsed.dedicated, with: newUrlsParsed.dedicated },
|
||||||
|
]
|
||||||
|
|
||||||
if (context() === "cloud") { var replacements = cloudReplacements }
|
if (context() === "cloud") { var replacements = cloudReplacements }
|
||||||
|
else if (context() === "dedicated") { var replacements = dedicatedReplacements }
|
||||||
else if (context() === "oss/enterprise") { var replacements = ossReplacements }
|
else if (context() === "oss/enterprise") { var replacements = ossReplacements }
|
||||||
else if ( preference === "cloud" ) { var replacements = cloudReplacements }
|
else if ( preference === "cloud" ) { var replacements = cloudReplacements }
|
||||||
else { var replacements = ossReplacements }
|
else { var replacements = ossReplacements }
|
||||||
|
@ -193,7 +222,7 @@ function updateUrls(prevUrls, newUrls) {
|
||||||
var endsWithSeparator = new RegExp('[-.:]');
|
var endsWithSeparator = new RegExp('[-.:]');
|
||||||
if(!startsWithSeparator.test(startStr) && !endsWithSeparator.test(endStr)) {
|
if(!startsWithSeparator.test(startStr) && !endsWithSeparator.test(endStr)) {
|
||||||
var newHost = startStr + replacement + endStr
|
var newHost = startStr + replacement + endStr
|
||||||
return startStr + replacement + endStr;
|
return newHost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,10 +248,12 @@ function updateUrls(prevUrls, newUrls) {
|
||||||
// Append the URL selector button to each codeblock with an InfluxDB Cloud or OSS URL
|
// Append the URL selector button to each codeblock with an InfluxDB Cloud or OSS URL
|
||||||
function appendUrlSelector() {
|
function appendUrlSelector() {
|
||||||
|
|
||||||
var appendToUrls = [ placeholderUrls.cloud, placeholderUrls.oss ]
|
var appendToUrls = [ placeholderUrls.cloud, placeholderUrls.oss, placeholderUrls.dedicated ]
|
||||||
|
|
||||||
if (context() === "cloud") {
|
if (context() === "cloud") {
|
||||||
var selectorText = "InfluxDB Cloud Region"
|
var selectorText = "InfluxDB Cloud Region"
|
||||||
|
} else if (context() === "dedicated") {
|
||||||
|
var selectorText = "Set dedicated cluster URL"
|
||||||
} else if (context() === "oss/enterprise") {
|
} else if (context() === "oss/enterprise") {
|
||||||
var selectorText = "Change InfluxDB URL"
|
var selectorText = "Change InfluxDB URL"
|
||||||
} else {
|
} else {
|
||||||
|
@ -320,6 +351,12 @@ $('input[name="influxdb-oss-url"]').change(function() {
|
||||||
})
|
})
|
||||||
$('input[name="influxdb-oss-url"]').click(function() {setPreference("oss")})
|
$('input[name="influxdb-oss-url"]').click(function() {setPreference("oss")})
|
||||||
|
|
||||||
|
$('input[name="influxdb-dedicated-url"]').change(function() {
|
||||||
|
var newUrl = $(this).val()
|
||||||
|
storeUrl("dedicated", newUrl, getUrls().dedicated)
|
||||||
|
updateUrls(getPrevUrls(), getUrls())
|
||||||
|
})
|
||||||
|
|
||||||
// Toggle preference tabs
|
// Toggle preference tabs
|
||||||
function togglePrefBtns(el) {
|
function togglePrefBtns(el) {
|
||||||
preference = el.length ? el.attr("id").replace("pref-", "") : "cloud"
|
preference = el.length ? el.attr("id").replace("pref-", "") : "cloud"
|
||||||
|
@ -353,6 +390,14 @@ showPreference()
|
||||||
|
|
||||||
// Validate custom URLs
|
// Validate custom URLs
|
||||||
function validateUrl(url) {
|
function validateUrl(url) {
|
||||||
|
/** validDomain = (Named host | IPv6 host | IPvFuture host)(:Port)? **/
|
||||||
|
var validDomain = new RegExp(`([a-z0-9\-._~%]+`
|
||||||
|
+ `|\[[a-f0-9:.]+\]`
|
||||||
|
+ `|\[v[a-f0-9][a-z0-9\-._~%!$&'()*+,;=:]+\])`
|
||||||
|
+ `(:[0-9]+)?`);
|
||||||
|
|
||||||
|
if (context() !== 'dedicated') {
|
||||||
|
// Validation for non-dedicated custom InfluxDB URLs
|
||||||
try {
|
try {
|
||||||
new URL(url);
|
new URL(url);
|
||||||
return {valid: true, error: ""}
|
return {valid: true, error: ""}
|
||||||
|
@ -360,11 +405,7 @@ function validateUrl(url) {
|
||||||
var validProtocol = /^http(s?)/
|
var validProtocol = /^http(s?)/
|
||||||
var protocol = url.match(/http(s?):\/\//) ? url.match(/http(s?):\/\//)[0] : "";
|
var protocol = url.match(/http(s?):\/\//) ? url.match(/http(s?):\/\//)[0] : "";
|
||||||
var domain = url.replace(protocol, "")
|
var domain = url.replace(protocol, "")
|
||||||
/** validDomain = (Named host | IPv6 host | IPvFuture host)(:Port)? **/
|
|
||||||
var validDomain = new RegExp(`([a-z0-9\-._~%]+`
|
|
||||||
+ `|\[[a-f0-9:.]+\]`
|
|
||||||
+ `|\[v[a-f0-9][a-z0-9\-._~%!$&'()*+,;=:]+\])`
|
|
||||||
+ `(:[0-9]+)?`);
|
|
||||||
if (validProtocol.test(protocol) == false) {
|
if (validProtocol.test(protocol) == false) {
|
||||||
return {valid: false, error: "Invalid protocol, use http[s]"}
|
return {valid: false, error: "Invalid protocol, use http[s]"}
|
||||||
} else if (validDomain.test(domain) == false) {
|
} else if (validDomain.test(domain) == false) {
|
||||||
|
@ -373,6 +414,22 @@ function validateUrl(url) {
|
||||||
return {valid: false, error: "Invalid URL"}
|
return {valid: false, error: "Invalid URL"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Validation for dedicated URLs
|
||||||
|
var includesProtocol = /^.*:\/\//
|
||||||
|
var protocol = url.match(/^.*:\/\//) ? url.match(/^.*:\/\//)[0] : "";
|
||||||
|
var domain = url.replace(protocol, "")
|
||||||
|
|
||||||
|
if (url.length === 0) {
|
||||||
|
return {valid: true, error: ""}
|
||||||
|
} else if (includesProtocol.test(protocol) == true) {
|
||||||
|
return {valid: false, error: "Do not include the protocol"}
|
||||||
|
} else if (validDomain.test(domain) == false) {
|
||||||
|
return {valid: false, error: "Invalid domain"}
|
||||||
|
} else {
|
||||||
|
return {valid: true, error: ""}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show validation errors
|
// Show validation errors
|
||||||
|
@ -400,7 +457,6 @@ function applyCustomUrl() {
|
||||||
} else {
|
} else {
|
||||||
showValidationMessage(urlValidation)
|
showValidationMessage(urlValidation)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
removeCustomUrl();
|
removeCustomUrl();
|
||||||
hideValidationMessage()
|
hideValidationMessage()
|
||||||
|
@ -408,6 +464,26 @@ function applyCustomUrl() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the dedicated URL cookie and apply the change
|
||||||
|
// If the dedicated URL field is empty, it defaults to the dedicated default
|
||||||
|
function applyDedicatedUrl() {
|
||||||
|
var dedicatedUrl = $('#dedicated-url-field').val()
|
||||||
|
let urlValidation = validateUrl(dedicatedUrl)
|
||||||
|
if (dedicatedUrl.length > 0 ) {
|
||||||
|
if (urlValidation.valid) {
|
||||||
|
hideValidationMessage()
|
||||||
|
storeDedicatedUrl(dedicatedUrl)
|
||||||
|
getUrls("dedicated", dedicatedUrl, getUrls().dedicated)
|
||||||
|
updateUrls(getPrevUrls(), getUrls())
|
||||||
|
} else {
|
||||||
|
showValidationMessage(urlValidation)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
removeDedicatedUrl();
|
||||||
|
hideValidationMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Trigger radio button on custom URL field focus
|
// Trigger radio button on custom URL field focus
|
||||||
$('input#custom-url-field').focus(function(e) {
|
$('input#custom-url-field').focus(function(e) {
|
||||||
$('input#custom[type="radio"]').trigger('click')
|
$('input#custom[type="radio"]').trigger('click')
|
||||||
|
@ -416,20 +492,23 @@ $('input#custom-url-field').focus(function(e) {
|
||||||
// Update URLs and close modal when using 'enter' to exit custom URL field
|
// Update URLs and close modal when using 'enter' to exit custom URL field
|
||||||
$("#custom-url").submit(function(e) {
|
$("#custom-url").submit(function(e) {
|
||||||
let url = $('#custom-url-field').val() ? $('#custom-url-field').val() : ""
|
let url = $('#custom-url-field').val() ? $('#custom-url-field').val() : ""
|
||||||
|
if (context() === 'dedicated') {
|
||||||
|
url = $('#dedicated-url-field').val() ? $('#dedicated-url-field').val() : ""
|
||||||
|
}
|
||||||
let urlValidation = validateUrl(url)
|
let urlValidation = validateUrl(url)
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (url === "" | urlValidation.valid) {
|
if (url === "" | urlValidation.valid) {
|
||||||
applyCustomUrl()
|
(context() !== 'dedicated') ? applyCustomUrl() : applyDedicatedUrl();
|
||||||
$('#modal-close').trigger('click')
|
$('#modal-close').trigger('click')
|
||||||
} else {
|
} else {
|
||||||
showValidationMessage(urlValidation)
|
showValidationMessage(urlValidation)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Store the custom InfluxDB URL when exiting the field
|
// Store the custom InfluxDB URL or dedicated URL when exiting the field
|
||||||
$('#custom-url-field').blur(function() {
|
$('#custom-url-field, #dedicated-url-field').blur(function() {
|
||||||
applyCustomUrl()
|
(context() !== 'dedicated') ? applyCustomUrl() : applyDedicatedUrl();
|
||||||
})
|
})
|
||||||
|
|
||||||
/** Delay execution of a function `fn` for a number of milliseconds `ms`
|
/** Delay execution of a function `fn` for a number of milliseconds `ms`
|
||||||
|
@ -444,7 +523,7 @@ function delay(fn, ms) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleUrlValidation() {
|
function handleUrlValidation() {
|
||||||
let url = $('#custom-url-field').val()
|
let url = $('#custom-url-field, #dedicated-url-field').val()
|
||||||
let urlValidation = validateUrl(url)
|
let urlValidation = validateUrl(url)
|
||||||
if (urlValidation.valid) {
|
if (urlValidation.valid) {
|
||||||
hideValidationMessage()
|
hideValidationMessage()
|
||||||
|
@ -453,7 +532,7 @@ function handleUrlValidation() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// When in erred state, revalidate custom URL on keyup
|
// When in erred state, revalidate custom URL on keyup
|
||||||
$(document).on("keyup", "#custom-url-field", delay(handleUrlValidation, 500));
|
$(document).on("keyup", "#custom-url-field, #dedicated-url-field", delay(handleUrlValidation, 500));
|
||||||
|
|
||||||
// Populate the custom InfluxDB URL field on page load
|
// Populate the custom InfluxDB URL field on page load
|
||||||
if ( Cookies.get('influxdb_custom_url') != undefined ) {
|
if ( Cookies.get('influxdb_custom_url') != undefined ) {
|
||||||
|
@ -461,6 +540,12 @@ if ( Cookies.get('influxdb_custom_url') != undefined ) {
|
||||||
$('#custom-url-field').val(Cookies.get('influxdb_custom_url'))
|
$('#custom-url-field').val(Cookies.get('influxdb_custom_url'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Populate the dedicated URL field on page load
|
||||||
|
if ( Cookies.get('influxdb_dedicated_url') != undefined ) {
|
||||||
|
$('input#dedicated-url-field').val(Cookies.get('influxdb_dedicated_url'))
|
||||||
|
$('#dedicated-url-field').val(Cookies.get('influxdb_dedicated_url'))
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/////////////////////////// Dynamically update URLs ////////////////////////////
|
/////////////////////////// Dynamically update URLs ////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -97,5 +97,6 @@ function activateTabs(selector, tab) {
|
||||||
**/
|
**/
|
||||||
var tab = getApiLibPreference();
|
var tab = getApiLibPreference();
|
||||||
(['.code-tabs']).forEach(selector => activateTabs(selector, tab), updateBtnURLs(tab));
|
(['.code-tabs']).forEach(selector => activateTabs(selector, tab), updateBtnURLs(tab));
|
||||||
|
|
||||||
tab = getTabQueryParam();
|
tab = getTabQueryParam();
|
||||||
(['.tabs', '.code-tabs']).forEach(selector => activateTabs(selector, tab), updateBtnURLs(tab));
|
(['.tabs', '.code-tabs']).forEach(selector => activateTabs(selector, tab), updateBtnURLs(tab));
|
||||||
|
|
|
@ -192,19 +192,21 @@ body.home {
|
||||||
h3 {
|
h3 {
|
||||||
margin: 0 0 1.5rem;
|
margin: 0 0 1.5rem;
|
||||||
line-height: 1.1em;
|
line-height: 1.1em;
|
||||||
font-size: 2.75rem;
|
font-size: 2.35rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.no-wrap { white-space: nowrap; }
|
||||||
|
|
||||||
p {
|
p {
|
||||||
margin-bottom: 2rem;
|
margin-bottom: 2rem;
|
||||||
};
|
}
|
||||||
|
|
||||||
.card-links {
|
.card-links {
|
||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
|
|
||||||
a {
|
a {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: block;
|
display: inline-block;
|
||||||
color: $article-text;
|
color: $article-text;
|
||||||
font-weight: $medium;
|
font-weight: $medium;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
@ -221,7 +223,7 @@ body.home {
|
||||||
|
|
||||||
&:hover{
|
&:hover{
|
||||||
color: $br-new-magenta;
|
color: $br-new-magenta;
|
||||||
&:after {width: 30%}
|
&:after {width: 100%}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,118 +260,134 @@ body.home {
|
||||||
|
|
||||||
#influxdb {
|
#influxdb {
|
||||||
|
|
||||||
padding-top: .5rem;
|
padding-top: 3rem;
|
||||||
display: flex;
|
|
||||||
|
|
||||||
.actions {
|
.categories {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
width: 100%;
|
||||||
align-items: center;
|
|
||||||
max-width: 50%;
|
|
||||||
padding: 0 3rem 3rem;
|
|
||||||
flex: 1 1 0;
|
flex: 1 1 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.category {
|
||||||
|
width: 50%;
|
||||||
|
margin-right: 2rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
&:last-child { margin-right: 0; }
|
||||||
|
|
||||||
|
.category-card{
|
||||||
|
padding: 3rem;
|
||||||
|
background: $sidebar-search-bg;
|
||||||
|
border-radius: 30px;
|
||||||
|
box-shadow: 1px 1px 7px $sidebar-search-shadow;
|
||||||
|
flex: 1 1 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
// justify-content: space-evenly;
|
||||||
|
|
||||||
|
.product {
|
||||||
|
margin-bottom: 2.5rem;
|
||||||
|
|
||||||
|
&:last-child{margin-bottom: 0;}
|
||||||
|
&.new{
|
||||||
|
h3:after {
|
||||||
|
content: "New";
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: .5rem;
|
||||||
|
padding: .15rem .35rem;
|
||||||
|
font-size: 1rem;
|
||||||
|
vertical-align: middle;
|
||||||
|
border-radius: $radius;
|
||||||
|
color: $br-dark-blue;
|
||||||
|
background-color: $br-chartreuse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-links {
|
||||||
|
margin-top: .9rem;
|
||||||
|
|
||||||
|
a {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
color: $article-text;
|
||||||
|
font-weight: $medium;
|
||||||
|
text-decoration: none;
|
||||||
|
|
||||||
|
&:after {
|
||||||
|
content: "";
|
||||||
|
display: block;
|
||||||
|
margin-top: .15rem;
|
||||||
|
border-top: 2px solid $br-new-magenta;
|
||||||
|
width: 0;
|
||||||
|
transition: width .2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover{
|
||||||
|
color: $br-new-magenta;
|
||||||
|
&:after {width: 100%}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:not(:first-child) {
|
||||||
|
position: relative;
|
||||||
|
margin-left: 1.8rem;
|
||||||
|
&:before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
display: inline-block;
|
||||||
|
left: -1rem;
|
||||||
|
top: .1rem;
|
||||||
|
height: 1em;
|
||||||
|
width: 1px;
|
||||||
|
margin-right: 1rem;
|
||||||
|
border-left: 1px solid rgba($article-text, .5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 3.5rem;
|
font-size: 3.5rem;
|
||||||
line-height: 1.1em;
|
line-height: 1.1em;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
& + p {
|
& + p {
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
margin: .5rem 0 2rem;
|
margin: .5rem 0 2rem;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
h3 {
|
h3 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
color: $g20-white;
|
font-size: 2rem;
|
||||||
font-size: 2.25rem;
|
color: $br-new-magenta;
|
||||||
|
.version {
|
||||||
|
opacity: .5;
|
||||||
|
font-size: .7em;
|
||||||
|
color: $article-bold;
|
||||||
|
transition: color .2s;}
|
||||||
|
& > a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: inherit;
|
||||||
|
transition: color .2s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: $article-bold;
|
||||||
|
.version {color: $article-bold;}
|
||||||
|
}
|
||||||
|
}
|
||||||
& + p {margin: .5rem 0;}
|
& + p {margin: .5rem 0;}
|
||||||
}
|
}
|
||||||
|
|
||||||
.hero-img {
|
h4 {
|
||||||
background-image: url('/img/wind-turbine.jpg');
|
font-size: 1.15rem;
|
||||||
background-size: cover;
|
margin: 1rem 0 .75rem 1.5rem;
|
||||||
margin: -.5rem .75rem 0 1rem;
|
|
||||||
z-index: -1;
|
|
||||||
min-height: 600px;
|
|
||||||
border-radius: 0 0 30px 30px;
|
|
||||||
flex: 1 1 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#influxdb-btn {
|
|
||||||
.exp-btn {
|
|
||||||
@include gradient($grad-burningDusk, 270deg);
|
|
||||||
color: $g20-white;
|
|
||||||
position: relative;
|
|
||||||
z-index: 1;
|
|
||||||
|
|
||||||
&:after {
|
|
||||||
content: "";
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
position: absolute;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
@include gradient($grad-coolDusk);
|
|
||||||
border-radius: 6px;
|
|
||||||
z-index: -1;
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity .2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover, &.open {
|
|
||||||
&:after {opacity: 1;}
|
|
||||||
}
|
|
||||||
|
|
||||||
&.open {
|
|
||||||
padding: 0;
|
|
||||||
li a {padding: 1rem 2rem;}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.exp-btn-links {
|
|
||||||
color: $g20-white;
|
|
||||||
li {
|
|
||||||
@include gradient($grad-coolDusk);
|
|
||||||
|
|
||||||
&:first-child {
|
|
||||||
a:after {border-radius: 6px 6px 0 0;}
|
|
||||||
}
|
|
||||||
|
|
||||||
&:not(:last-child) {border-bottom: 1px solid rgba($body-bg, .5);}
|
|
||||||
|
|
||||||
&:last-child a:after {border-radius: 0 0 6px 6px;}
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: $g20-white;
|
|
||||||
position: relative;
|
|
||||||
z-index: 1;
|
|
||||||
|
|
||||||
&:after {
|
|
||||||
content: "";
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
position: absolute;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
@include gradient($grad-burningDusk, 270deg);
|
|
||||||
border-radius: 6px;
|
|
||||||
z-index: -1;
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity .2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover:after {opacity: 1}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.close-btn {
|
|
||||||
color: rgba($br-new-magenta, .6);
|
|
||||||
&:hover {color: $br-new-magenta;}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,12 +561,13 @@ body.home {
|
||||||
|
|
||||||
@include media(medium) {
|
@include media(medium) {
|
||||||
#influxdb {
|
#influxdb {
|
||||||
.actions {
|
.categories {
|
||||||
max-width: 100%;
|
flex-direction: column;
|
||||||
padding-top: 3rem;
|
.category {
|
||||||
text-align: center;
|
width: 100%;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.hero-img {display: none}
|
|
||||||
}
|
}
|
||||||
#api-guides {
|
#api-guides {
|
||||||
.padding-wrapper{
|
.padding-wrapper{
|
||||||
|
@ -600,8 +619,16 @@ body.home {
|
||||||
h3 {font-size: 2rem;}
|
h3 {font-size: 2rem;}
|
||||||
}
|
}
|
||||||
#influxdb {
|
#influxdb {
|
||||||
.actions {padding: 2rem;}
|
h2 {font-size: 2.15rem; }
|
||||||
h2 {font-size: 2.65rem;}
|
.subhead {margin-bottom: 1.5rem;}
|
||||||
|
.categories {
|
||||||
|
.category-card {
|
||||||
|
padding: 2rem;
|
||||||
|
h3 {font-size: 1.75rem;}
|
||||||
|
|
||||||
|
.product { margin-bottom: 2rem; }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#api-guides {
|
#api-guides {
|
||||||
.padding-wrapper {
|
.padding-wrapper {
|
||||||
|
|
|
@ -9,9 +9,9 @@ pre[class*="language-"] {
|
||||||
word-break: normal;
|
word-break: normal;
|
||||||
word-wrap: normal;
|
word-wrap: normal;
|
||||||
|
|
||||||
-moz-tab-size: 1;
|
-moz-tab-size: 4;
|
||||||
-o-tab-size: 1;
|
-o-tab-size: 4;
|
||||||
tab-size: 1;
|
tab-size: 4;
|
||||||
|
|
||||||
-webkit-hyphens: none;
|
-webkit-hyphens: none;
|
||||||
-moz-hyphens: none;
|
-moz-hyphens: none;
|
||||||
|
|
|
@ -102,9 +102,10 @@
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
&.products{
|
&.products{
|
||||||
li {
|
|
||||||
&:before {
|
&:before {
|
||||||
|
content: attr(data-category);
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
margin: .75rem .75rem .15rem;
|
||||||
font-size: .85rem;
|
font-size: .85rem;
|
||||||
color: $g2-kevlar;
|
color: $g2-kevlar;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
|
@ -113,15 +114,6 @@
|
||||||
opacity: .65;
|
opacity: .65;
|
||||||
mix-blend-mode: multiply;
|
mix-blend-mode: multiply;
|
||||||
}
|
}
|
||||||
&:first-child:before {
|
|
||||||
content: "Products";
|
|
||||||
margin: .3rem .75rem .15rem;
|
|
||||||
}
|
|
||||||
&.flux:before {
|
|
||||||
content: "Languages";
|
|
||||||
margin: .75rem .75rem .15rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a {
|
a {
|
||||||
|
|
|
@ -321,6 +321,10 @@ table tr.point{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.hide-elements {p span.el { border: none; &:before, &:after {display: none}}}
|
||||||
|
&.hide-commas {p span.comma { border: none; &:before, &:after {display: none}}}
|
||||||
|
&.hide-whitespace {p span.whitespace { border: none; &:before, &:after {display: none}}}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -92,7 +92,8 @@ li.custom {
|
||||||
|
|
||||||
&.error {
|
&.error {
|
||||||
&:after { display: block; }
|
&:after { display: block; }
|
||||||
input#custom-url-field {
|
input#custom-url-field,
|
||||||
|
input#dedicated-url-field {
|
||||||
border-color: $r-fire;
|
border-color: $r-fire;
|
||||||
&:focus {
|
&:focus {
|
||||||
border-color: $r-fire;
|
border-color: $r-fire;
|
||||||
|
@ -102,7 +103,8 @@ li.custom {
|
||||||
}
|
}
|
||||||
|
|
||||||
input {
|
input {
|
||||||
&#custom-url-field {
|
&#custom-url-field,
|
||||||
|
&#dedicated-url-field {
|
||||||
font-family: $proxima;
|
font-family: $proxima;
|
||||||
font-weight: $medium;
|
font-weight: $medium;
|
||||||
background: $modal-field-bg;
|
background: $modal-field-bg;
|
||||||
|
@ -129,6 +131,16 @@ li.custom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#dedicated-urls {
|
||||||
|
.providers {
|
||||||
|
padding-bottom: 1rem;
|
||||||
|
}
|
||||||
|
#custom-url {
|
||||||
|
margin-top: .5rem;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.radio {
|
.radio {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
|
@ -31,7 +31,7 @@ $sidebar-search-highlight: $b-pool !default;
|
||||||
$sidebar-search-text: $g6-smoke !default;
|
$sidebar-search-text: $g6-smoke !default;
|
||||||
|
|
||||||
// Left Navigation
|
// Left Navigation
|
||||||
$nav-category: $b-dodger !default;
|
$nav-category: $b-ocean !default;
|
||||||
$nav-category-hover: $br-magenta !default;
|
$nav-category-hover: $br-magenta !default;
|
||||||
$nav-item: $g9-mountain !default;
|
$nav-item: $g9-mountain !default;
|
||||||
$nav-item-hover: $br-magenta !default;
|
$nav-item-hover: $br-magenta !default;
|
||||||
|
|
|
@ -34,6 +34,8 @@ smartDashes = false
|
||||||
"influxdb/v2.1/tag" = "influxdb/v2.1/tags"
|
"influxdb/v2.1/tag" = "influxdb/v2.1/tags"
|
||||||
"influxdb/v2.0/tag" = "influxdb/v2.0/tags"
|
"influxdb/v2.0/tag" = "influxdb/v2.0/tags"
|
||||||
"influxdb/cloud/tag" = "influxdb/cloud/tags"
|
"influxdb/cloud/tag" = "influxdb/cloud/tags"
|
||||||
|
"influxdb/cloud-serverless/tag" = "influxdb/cloud-serverless/tags"
|
||||||
|
"influxdb/cloud-dedicated/tag" = "influxdb/cloud-dedicated/tags"
|
||||||
"flux/v0.x/tag" = "flux/v0.x/tags"
|
"flux/v0.x/tag" = "flux/v0.x/tags"
|
||||||
|
|
||||||
[markup]
|
[markup]
|
||||||
|
|
|
@ -30,7 +30,8 @@ smartDashes = false
|
||||||
"influxdb/v2.1/tag" = "influxdb/v2.1/tags"
|
"influxdb/v2.1/tag" = "influxdb/v2.1/tags"
|
||||||
"influxdb/v2.0/tag" = "influxdb/v2.0/tags"
|
"influxdb/v2.0/tag" = "influxdb/v2.0/tags"
|
||||||
"influxdb/cloud/tag" = "influxdb/cloud/tags"
|
"influxdb/cloud/tag" = "influxdb/cloud/tags"
|
||||||
"influxdb/cloud-iox/tag" = "influxdb/cloud-iox/tags"
|
"influxdb/cloud-serverless/tag" = "influxdb/cloud-serverless/tags"
|
||||||
|
"influxdb/cloud-dedicated/tag" = "influxdb/cloud-dedicated/tags"
|
||||||
"flux/v0.x/tag" = "flux/v0.x/tags"
|
"flux/v0.x/tag" = "flux/v0.x/tags"
|
||||||
|
|
||||||
[markup]
|
[markup]
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
---
|
||||||
|
title: InfluxDB Cloud Dedicated documentation
|
||||||
|
description: >
|
||||||
|
InfluxDB Cloud Dedicated is a hosted and managed InfluxDB Cloud cluster
|
||||||
|
dedicated to a single tenant.
|
||||||
|
The InfluxDB time series platform is designed to handle high write and query loads.
|
||||||
|
Learn how to use and leverage InfluxDB Cloud Dedicated for your specific
|
||||||
|
time series use case.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: InfluxDB Cloud Dedicated
|
||||||
|
weight: 1
|
||||||
|
---
|
||||||
|
|
||||||
|
InfluxDB Cloud Dedicated is a hosted and managed InfluxDB Cloud cluster
|
||||||
|
dedicated to a single tenant.
|
||||||
|
The InfluxDB time series platform is designed to handle high write and query loads.
|
||||||
|
Learn how to use and leverage InfluxDB Cloud Dedicated for your specific
|
||||||
|
time series use case.
|
||||||
|
|
||||||
|
<a class="btn" href="{{< dedicated-link >}}">Request an InfluxDB Cloud Dedicated cluster</a>
|
||||||
|
<a class="btn" href="/influxdb/cloud-dedicated/get-started/">Get started with InfluxDB Cloud Dedicated</a>
|
||||||
|
|
||||||
|
## The InfluxDB IOx storage engine
|
||||||
|
|
||||||
|
**InfluxDB IOx** is InfluxDB's next generation storage engine that unlocks series
|
||||||
|
limitations present in the Time Structured Merge Tree (TSM) storage engine.
|
||||||
|
InfluxDB IOx allows infinite series cardinality without any impact on
|
||||||
|
overall database performance. It also brings with it native
|
||||||
|
**SQL support** and improved InfluxQL performance.
|
||||||
|
|
||||||
|
View the following video for more information about InfluxDB IOx:
|
||||||
|
|
||||||
|
{{< youtube "CzWVcDxmWbM" >}}
|
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
title: Administer InfluxDB Cloud Dedicated
|
||||||
|
description: >
|
||||||
|
Perform administrative tasks in your InfluxDB Cloud Dedicated cluster such as
|
||||||
|
creating and managing tokens and databases.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Administer InfluxDB
|
||||||
|
weight: 5
|
||||||
|
---
|
||||||
|
|
||||||
|
The following articles provide information about managing your InfluxDB Cloud
|
||||||
|
Dedicated resources:
|
||||||
|
|
||||||
|
{{< children >}}
|
|
@ -0,0 +1,51 @@
|
||||||
|
---
|
||||||
|
title: Manage databases
|
||||||
|
seotitle: Manage databases in InfluxDB Cloud Dedicated
|
||||||
|
description: >
|
||||||
|
Manage databases in your InfluxDB Cloud Dedicated cluster.
|
||||||
|
A database is a named location where time series data is stored.
|
||||||
|
Each InfluxDB database has a retention period, which defines the maximum age
|
||||||
|
of data stored in the database.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: Administer InfluxDB
|
||||||
|
weight: 101
|
||||||
|
influxdb/cloud-dedicated/tags: [databases]
|
||||||
|
---
|
||||||
|
|
||||||
|
An InfluxDB database is a named location where time series data is stored.
|
||||||
|
Each InfluxDB database has a [retention period](#retention-periods).
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
**If coming from InfluxDB v1**, the concepts of databases and retention policies
|
||||||
|
have been combined into a single concept--database. Retention policies are no
|
||||||
|
longer part of the InfluxDB data model. However, InfluxDB Cloud Dedicated does
|
||||||
|
support InfluxQL, which requires databases and retention policies.
|
||||||
|
See [InfluxQL DBRP naming convention](/influxdb/cloud-dedicated/admin/databases/create/#influxql-dbrp-naming-convention).
|
||||||
|
|
||||||
|
**If coming from InfluxDB v2 or InfluxDB Cloud**, _database_ and _bucket_ are synonymous.
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
|
## Retention periods
|
||||||
|
|
||||||
|
A database **retention period** is the maximum age of data stored in the database.
|
||||||
|
The age of data is determined by the timestamp associated with each point.
|
||||||
|
When a point's timestamp is beyond the retention period (relative to now), the
|
||||||
|
point is marked for deletion and is removed from the database the next time the
|
||||||
|
retention enforcement service runs.
|
||||||
|
|
||||||
|
The _minimum_ retention period for and InfluxDB database is 1 hour.
|
||||||
|
The _maximum_ retention period is infinite meaning data does not expire and will
|
||||||
|
never be removed by the retention enforcement service.
|
||||||
|
|
||||||
|
{{% warn %}}
|
||||||
|
#### Retention periods cannot be updated
|
||||||
|
|
||||||
|
Retention periods cannot be changed after a database is created.
|
||||||
|
To move to a different retention period, create a new database with the retention
|
||||||
|
period you want and migrate existing data to the new database.
|
||||||
|
{{% /warn %}}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
{{< children hlevel="h2" readmore=true hr=true >}}
|
|
@ -0,0 +1,112 @@
|
||||||
|
---
|
||||||
|
title: Create a database
|
||||||
|
description: >
|
||||||
|
Use the [`influxctl database create` command](/influxdb/cloud-dedicated/reference/cli/influxctl/database/create/)
|
||||||
|
to create a new InfluxDB database in your InfluxDB Cloud Dedicated cluster.
|
||||||
|
Provide a database name and an optional retention period.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: Manage databases
|
||||||
|
weight: 201
|
||||||
|
list_code_example: |
|
||||||
|
```sh
|
||||||
|
influxctl database create --retention-period 30d <DATABASE_NAME>
|
||||||
|
```
|
||||||
|
---
|
||||||
|
|
||||||
|
Use the [`influxctl database create` command](/influxdb/cloud-dedicated/reference/cli/influxctl/database/create/)
|
||||||
|
to create a database in your InfluxDB Cloud Dedicated cluster.
|
||||||
|
|
||||||
|
1. If you haven't already, [download and install the `influxctl` CLI](/influxdb/cloud-dedicated/reference/cli/influxctl/#download-and-install-influxctl).
|
||||||
|
2. Run the `influxctl database create` command and provide the following:
|
||||||
|
|
||||||
|
- _(Optional)_ Database [retention period](/influxdb/cloud-dedicated/admin/databases/#retention-periods)
|
||||||
|
(default is infinite)
|
||||||
|
- Database name _(see [Database naming restrictions](#database-naming-restrictions))_
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl database create --retention-period 30d <DATABASE_NAME>
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% warn %}}
|
||||||
|
#### Retention periods cannot be updated
|
||||||
|
|
||||||
|
Retention periods cannot be changed after a database is created.
|
||||||
|
To move to a different retention period, create a new database with the retention
|
||||||
|
period you want and migrate existing data to the new database.
|
||||||
|
{{% /warn %}}
|
||||||
|
|
||||||
|
- [Retention period syntax](#retention-period-syntax)
|
||||||
|
- [Database naming restrictions](#database-naming-restrictions)
|
||||||
|
- [InfluxQL DBRP naming convention](#influxql-dbrp-naming-convention)
|
||||||
|
|
||||||
|
## Retention period syntax
|
||||||
|
|
||||||
|
Use the `--retention-period` flag to define a specific
|
||||||
|
[retention period](/influxdb/cloud-dedicated/admin/databases/#retention-periods)
|
||||||
|
for the database.
|
||||||
|
The retention period value is a time duration value made up of a numeric value
|
||||||
|
plus a duration unit. For example, `30d` means 30 days.
|
||||||
|
A zero duration retention period is infinite and data will not expire.
|
||||||
|
The retention period value cannot be negative or contain whitespace.
|
||||||
|
|
||||||
|
{{< flex >}}
|
||||||
|
{{% flex-content %}}
|
||||||
|
|
||||||
|
##### Valid durations units include
|
||||||
|
|
||||||
|
- **m**: minute
|
||||||
|
- **h**: hour
|
||||||
|
- **d**: day
|
||||||
|
- **w**: week
|
||||||
|
- **mo**: month
|
||||||
|
- **y**: year
|
||||||
|
|
||||||
|
{{% /flex-content %}}
|
||||||
|
{{% flex-content %}}
|
||||||
|
|
||||||
|
##### Example retention period values
|
||||||
|
|
||||||
|
- `0d`: infinite/none
|
||||||
|
- `3d`: 3 days
|
||||||
|
- `6w`: 6 weeks
|
||||||
|
- `1mo`: 1 month (30 days)
|
||||||
|
- `1y`: 1 year
|
||||||
|
- `30d30d`: 60 days
|
||||||
|
- `2.5d`: 60 hours
|
||||||
|
|
||||||
|
{{% /flex-content %}}
|
||||||
|
{{< /flex >}}
|
||||||
|
|
||||||
|
## Database naming restrictions
|
||||||
|
|
||||||
|
Database names must adhere to the following naming restrictions:
|
||||||
|
|
||||||
|
- Must contain two or more characters
|
||||||
|
- Cannot start with an underscore (`_`)
|
||||||
|
- Cannot contain whitespace characters, double quotes (`"`), or percent signs (`%`)
|
||||||
|
|
||||||
|
## InfluxQL DBRP naming convention
|
||||||
|
|
||||||
|
In InfluxDB 1.x, data is stored in [databases](/{{< latest "influxdb" "v1" >}}/concepts/glossary/#database)
|
||||||
|
and [retention policies](/{{< latest "influxdb" "v1" >}}/concepts/glossary/#retention-policy-rp).
|
||||||
|
In InfluxDB Cloud Dedicated, databases and retention policies have been merged into
|
||||||
|
_databases_, where databases have a retention period, but retention policies
|
||||||
|
are no longer part of the data model.
|
||||||
|
Because InfluxQL uses the 1.x data model, a database must be mapped to a v1
|
||||||
|
database and retention policy (DBRP) to be queryable with InfluxQL.
|
||||||
|
|
||||||
|
**When naming a database that you want to query with InfluxQL**, use the following
|
||||||
|
naming convention to automatically map v1 DBRP combinations to a database:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
database_name/retention_policy_name
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Database naming examples
|
||||||
|
|
||||||
|
| v1 Database name | v1 Retention Policy name | New database name |
|
||||||
|
| :--------------- | :----------------------- | :------------------------ |
|
||||||
|
| db | rp | db/rp |
|
||||||
|
| telegraf | autogen | telegraf/autogen |
|
||||||
|
| webmetrics | 1w-downsampled | webmetrics/1w-downsampled |
|
|
@ -0,0 +1,39 @@
|
||||||
|
---
|
||||||
|
title: Delete a database
|
||||||
|
description: >
|
||||||
|
Use the [`influxctl database delete` command](/influxdb/cloud-dedicated/reference/cli/influxctl/database/delete/)
|
||||||
|
to delete a database from your InfluxDB Cloud Dedicated cluster.
|
||||||
|
Provide the name of the database you want to delete.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: Manage databases
|
||||||
|
weight: 203
|
||||||
|
list_code_example: |
|
||||||
|
```sh
|
||||||
|
influxctl database delete <DATABASE_NAME>
|
||||||
|
```
|
||||||
|
---
|
||||||
|
|
||||||
|
Use the [`influxctl database delete` command](/influxdb/cloud-dedicated/reference/cli/influxctl/database/delete/)
|
||||||
|
to delete a database from your InfluxDB Cloud Dedicated cluster.
|
||||||
|
|
||||||
|
1. If you haven't already, [download and install the `influxctl` CLI](/influxdb/cloud-dedicated/reference/cli/influxctl/#download-and-install-influxctl).
|
||||||
|
2. Run the `influxctl database delete` command and provide the following:
|
||||||
|
|
||||||
|
- Name of the database to delete
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl database delete <DATABASE_NAME>
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Confirm that you want to delete the database.
|
||||||
|
|
||||||
|
{{% warn %}}
|
||||||
|
#### Deleting a database cannot be undone
|
||||||
|
|
||||||
|
Once a database is deleted, data stored in that database cannot be recovered.
|
||||||
|
|
||||||
|
#### Cannot reuse database names
|
||||||
|
|
||||||
|
After a database is deleted, you cannot reuse the same name for a new database.
|
||||||
|
{{% /warn %}}
|
|
@ -0,0 +1,56 @@
|
||||||
|
---
|
||||||
|
title: List databases
|
||||||
|
description: >
|
||||||
|
Use the [`influxctl database list` command](/influxdb/cloud-dedicated/reference/cli/influxctl/database/list/)
|
||||||
|
to list databases in your InfluxDB Cloud Dedicated cluster.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: Manage databases
|
||||||
|
weight: 202
|
||||||
|
list_code_example: |
|
||||||
|
```sh
|
||||||
|
influxctl database list
|
||||||
|
```
|
||||||
|
---
|
||||||
|
|
||||||
|
Use the [`influxctl database list` command](/influxdb/cloud-dedicated/reference/cli/influxctl/database/list/)
|
||||||
|
to list databases in your InfluxDB Cloud Dedicated cluster.
|
||||||
|
|
||||||
|
1. If you haven't already, [download and install the `influxctl` CLI](/influxdb/cloud-dedicated/reference/cli/influxctl/#download-and-install-influxctl).
|
||||||
|
2. Run `influxctl database list` with the following:
|
||||||
|
|
||||||
|
- _(Optional)_ [Output format](#output-formats)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl database list --format table
|
||||||
|
```
|
||||||
|
|
||||||
|
### Output formats
|
||||||
|
|
||||||
|
The `influxctl database list` command supports two output formats: `table` and `json`.
|
||||||
|
By default, the command outputs the list of databases formatted as a table.
|
||||||
|
For easier programmatic access to the command output, include `--format json`
|
||||||
|
with your command to format the database list as JSON.
|
||||||
|
|
||||||
|
#### Example output
|
||||||
|
|
||||||
|
{{< code-tabs-wrapper >}}
|
||||||
|
{{% code-tabs %}}
|
||||||
|
[table](#)
|
||||||
|
[json](#)
|
||||||
|
{{% /code-tabs %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Insert table output
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
|
||||||
|
```json
|
||||||
|
// Insert json output
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{< /code-tabs-wrapper >}}
|
|
@ -0,0 +1,40 @@
|
||||||
|
---
|
||||||
|
title: Manage tokens
|
||||||
|
seotitle: Manage tokens in InfluxDB Cloud Dedicated
|
||||||
|
description: >
|
||||||
|
Manage database tokens in your InfluxDB Cloud Dedicated cluster.
|
||||||
|
Database tokens grant read and write permissions to one or more databases and
|
||||||
|
allow for actions like writing and querying data.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: Administer InfluxDB
|
||||||
|
weight: 101
|
||||||
|
influxdb/cloud-dedicated/tags: [tokens]
|
||||||
|
---
|
||||||
|
|
||||||
|
InfluxDB uses token authentication to authorize access to data in your InfluxDB
|
||||||
|
Cloud Dedicated cluster. Each token grants read and write permissions to one or
|
||||||
|
more databases and allows for actions like writing and querying data.
|
||||||
|
|
||||||
|
All read and write actions performed against time series data in your InfluxDB
|
||||||
|
Cloud Dedicated cluster must be authorized using a token. Administrative actions
|
||||||
|
such as managing tokens and databases are authorized using **management tokens**
|
||||||
|
issued by **Auth0**. Management tokens allow clients, such as the `influxctl` CLI,
|
||||||
|
to perform administrative actions.
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
#### Store secure tokens in a secret store
|
||||||
|
|
||||||
|
Token strings are returned _only_ on token creation.
|
||||||
|
We recommend storing database tokens in a secure secret store.
|
||||||
|
|
||||||
|
#### Tokens cannot be updated
|
||||||
|
|
||||||
|
Once created, token permissions cannot be updated.
|
||||||
|
If you need a token with different permissions, create a token with the
|
||||||
|
appropriate permissions.
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
{{< children hlevel="h2" readmore=true hr=true >}}
|
|
@ -0,0 +1,99 @@
|
||||||
|
---
|
||||||
|
title: Create a token
|
||||||
|
description: >
|
||||||
|
Use the [`influxctl token create` command](/influxdb/cloud-dedicated/reference/cli/influxctl/token/create/)
|
||||||
|
to create a database token in your InfluxDB Cloud Dedicated cluster.
|
||||||
|
Provide a token description and grant permissions to databases.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: Manage tokens
|
||||||
|
weight: 201
|
||||||
|
list_code_example: |
|
||||||
|
```sh
|
||||||
|
influxctl token create \
|
||||||
|
--write-database <DATABASE_NAME> \
|
||||||
|
--read-database <DATABASE_NAME> \
|
||||||
|
<TOKEN_DESCRIPTION>
|
||||||
|
```
|
||||||
|
---
|
||||||
|
|
||||||
|
Use the [`influxctl token create` command](/influxdb/cloud-dedicated/reference/cli/influxctl/token/create/)
|
||||||
|
to create a token that grants access to databases in your InfluxDB Cloud Dedicated cluster.
|
||||||
|
|
||||||
|
1. If you haven't already, [download and install the `influxctl` CLI](/influxdb/cloud-dedicated/reference/cli/influxctl/#download-and-install-influxctl).
|
||||||
|
2. Run the `influxctl token create` command and provide the following:
|
||||||
|
|
||||||
|
- Token permissions (read and write per database)
|
||||||
|
- `--read-database`: Grant read permissions to a database
|
||||||
|
- `--write-database`: Grant write permissions to a database
|
||||||
|
- Token description
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token create \
|
||||||
|
--read-database <DATABASE_NAME> \
|
||||||
|
--write-database <DATABASE_NAME> \
|
||||||
|
<TOKEN_DESCRIPTION>
|
||||||
|
```
|
||||||
|
|
||||||
|
The command returns the token ID and the token string.
|
||||||
|
**This is the only time the token string is available in plain text.**
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
#### Store secure tokens in a secret store
|
||||||
|
|
||||||
|
Token strings are returned _only_ on token creation.
|
||||||
|
We recommend storing database tokens in a secure secret store.
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
|
#### Example token creation commands
|
||||||
|
|
||||||
|
{{< expand-wrapper >}}
|
||||||
|
{{% expand "Create a token with read and write access to a database" %}}
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token create \
|
||||||
|
--read-database mydb \
|
||||||
|
--write-database mydb \
|
||||||
|
"Read/write token for mydb"
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
{{% expand "Create a token with read-only access to a database" %}}
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token create \
|
||||||
|
--read-database mydb \
|
||||||
|
"Read-only token for mydb"
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
{{% expand "Create a token with read-only access to multiple database" %}}
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token create \
|
||||||
|
--read-database mydb1 \
|
||||||
|
--read-database mydb2 \
|
||||||
|
"Read-only token for mydb1 and mydb2"
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
{{% expand "Create a token with mixed permissions on multiple database" %}}
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token create \
|
||||||
|
--read-database mydb1 \
|
||||||
|
--read-database mydb2 \
|
||||||
|
--write-database mydb2 \
|
||||||
|
"Read-only on mydb1, Read/write on mydb2"
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
{{< /expand-wrapper >}}
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
#### Tokens cannot be updated
|
||||||
|
|
||||||
|
Once created, token permissions cannot be updated.
|
||||||
|
If you need a token with different permissions, create a new token with the
|
||||||
|
appropriate permissions.
|
||||||
|
{{% /note %}}
|
|
@ -0,0 +1,52 @@
|
||||||
|
---
|
||||||
|
title: Delete a token
|
||||||
|
description: >
|
||||||
|
Use the [`influxctl token delete` command](/influxdb/cloud-dedicated/reference/cli/influxctl/token/delete/)
|
||||||
|
to delete a token from your InfluxDB Cloud Dedicated cluster and revoke all
|
||||||
|
permissions associated with the token.
|
||||||
|
Provide the ID of the token you want to delete.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: Manage tokens
|
||||||
|
weight: 203
|
||||||
|
list_code_example: |
|
||||||
|
```sh
|
||||||
|
influxctl token delete <TOKEN_ID>
|
||||||
|
```
|
||||||
|
---
|
||||||
|
|
||||||
|
Use the [`influxctl token delete` command](/influxdb/cloud-dedicated/reference/cli/influxctl/token/delete/)
|
||||||
|
to delete a database token from your InfluxDB Cloud Dedicated cluster and revoke
|
||||||
|
all permissions associated with the token.
|
||||||
|
|
||||||
|
1. If you haven't already, [download and install the `influxctl` CLI](/influxdb/cloud-dedicated/reference/cli/influxctl/#download-and-install-influxctl).
|
||||||
|
2. Run the [`influxctl token list` command](/influxdb/cloud-dedicated/reference/cli/influxctl/token/list)
|
||||||
|
to output tokens with their IDs.
|
||||||
|
Copy the **token ID** of the token you want to delete.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token list
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Run the `influxctl token delete` command and provide the following:
|
||||||
|
|
||||||
|
- Token ID to delete
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token delete <TOKEN_ID>
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Confirm that you want to delete the token.
|
||||||
|
|
||||||
|
{{% warn %}}
|
||||||
|
#### Deleting a token is immediate and cannot be undone
|
||||||
|
|
||||||
|
Deleting a database token is a destructive action that takes place immediately
|
||||||
|
and cannot be undone.
|
||||||
|
|
||||||
|
#### Rotate deleted tokens
|
||||||
|
|
||||||
|
After deleting a database token, any clients using the deleted token need to be
|
||||||
|
updated with a new database token to continue to interact with your InfluxDB
|
||||||
|
Cloud Dedicated cluster.
|
||||||
|
{{% /warn %}}
|
|
@ -0,0 +1,56 @@
|
||||||
|
---
|
||||||
|
title: List tokens
|
||||||
|
description: >
|
||||||
|
Use the [`influxctl token list` command](/influxdb/cloud-dedicated/reference/cli/influxctl/token/list/)
|
||||||
|
to list tokens in your InfluxDB Cloud Dedicated cluster.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: Manage tokens
|
||||||
|
weight: 202
|
||||||
|
list_code_example: |
|
||||||
|
```sh
|
||||||
|
influxctl token list
|
||||||
|
```
|
||||||
|
---
|
||||||
|
|
||||||
|
Use the [`influxctl token list` command](/influxdb/cloud-dedicated/reference/cli/influxctl/token/list/)
|
||||||
|
to list database tokens in your InfluxDB Cloud Dedicated cluster.
|
||||||
|
|
||||||
|
1. If you haven't already, [download and install the `influxctl` CLI](/influxdb/cloud-dedicated/reference/cli/influxctl/#download-and-install-influxctl).
|
||||||
|
2. Run `influxctl token list` with the following:
|
||||||
|
|
||||||
|
- _(Optional)_ [Output format](#output-formats)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token list --format table
|
||||||
|
```
|
||||||
|
|
||||||
|
### Output formats
|
||||||
|
|
||||||
|
The `influxctl token list` command supports two output formats: `table` and `json`.
|
||||||
|
By default, the command outputs the list of tokens formatted as a table.
|
||||||
|
For easier programmatic access to the command output, include `--format json`
|
||||||
|
with your command to format the token list as JSON.
|
||||||
|
|
||||||
|
#### Example output
|
||||||
|
|
||||||
|
{{< code-tabs-wrapper >}}
|
||||||
|
{{% code-tabs %}}
|
||||||
|
[table](#)
|
||||||
|
[json](#)
|
||||||
|
{{% /code-tabs %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Insert table output
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
|
||||||
|
```json
|
||||||
|
// Insert json output
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{< /code-tabs-wrapper >}}
|
|
@ -0,0 +1,120 @@
|
||||||
|
---
|
||||||
|
title: Get started with InfluxDB Cloud Dedicated
|
||||||
|
list_title: Get started
|
||||||
|
description: >
|
||||||
|
Start writing and querying time series data in InfluxDB Cloud Dedicated.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Get started
|
||||||
|
weight: 3
|
||||||
|
influxdb/cloud-dedicated/tags: [get-started]
|
||||||
|
---
|
||||||
|
|
||||||
|
InfluxDB Cloud Dedicated is the platform purpose-built to collect, store, and
|
||||||
|
query time series data.
|
||||||
|
It is powered by the InfluxDB IOx storage engine which provides a number of
|
||||||
|
benefits including nearly unlimited series cardinality, improved query performance,
|
||||||
|
and interoperability with widely used data processing tools and platforms.
|
||||||
|
|
||||||
|
**Time series data** is a sequence of data points indexed in time order.
|
||||||
|
Data points typically consist of successive measurements made from the same
|
||||||
|
source and are used to track changes over time.
|
||||||
|
Examples of time series data include:
|
||||||
|
|
||||||
|
- Industrial sensor data
|
||||||
|
- Server performance metrics
|
||||||
|
- Heartbeats per minute
|
||||||
|
- Electrical activity in the brain
|
||||||
|
- Rainfall measurements
|
||||||
|
- Stock prices
|
||||||
|
|
||||||
|
This multi-part tutorial walks you through writing time series data to
|
||||||
|
your dedicated InfluxDB Cloud cluster, querying, and then visualizing that data.
|
||||||
|
|
||||||
|
## Key concepts before you get started
|
||||||
|
|
||||||
|
Before you get started using InfluxDB, it's important to understand how time series
|
||||||
|
data is organized and stored in InfluxDB and some key definitions that are used
|
||||||
|
throughout this documentation.
|
||||||
|
|
||||||
|
- [Data organization](#data-organization)
|
||||||
|
- [Schema on write](#schema-on-write)
|
||||||
|
- [Important definitions](#important-definitions)
|
||||||
|
|
||||||
|
### Data organization
|
||||||
|
|
||||||
|
The InfluxDB Cloud Dedicated data model organizes time series data into databases
|
||||||
|
and measurements. A database can contain multiple measurements.
|
||||||
|
Measurements contain multiple tags and fields.
|
||||||
|
|
||||||
|
- **Database**: Named location where time series data is stored.
|
||||||
|
A database can contain multiple _measurements_.
|
||||||
|
- **Measurement**: Logical grouping for time series data.
|
||||||
|
All _points_ in a given measurement should have the same _tags_.
|
||||||
|
A measurement contains multiple _tags_ and _fields_.
|
||||||
|
- **Tags**: Key-value pairs that provide metadata for each point--for example,
|
||||||
|
something to identify the source or context of the data like host,
|
||||||
|
location, station, etc.
|
||||||
|
- **Fields**: Key-value pairs with values that change over time--for example,
|
||||||
|
temperature, pressure, stock price, etc.
|
||||||
|
- **Timestamp**: Timestamp associated with the data.
|
||||||
|
When stored on disk and queried, all data is ordered by time.
|
||||||
|
|
||||||
|
### Schema on write
|
||||||
|
|
||||||
|
When using InfluxDB, you define your schema as you write your data.
|
||||||
|
You don't need to create measurements (equivalent to a relational table) or
|
||||||
|
explicitly define the schema of the measurement.
|
||||||
|
Measurement schemas are defined by the schema of data as it is written to the measurement.
|
||||||
|
|
||||||
|
### Important definitions
|
||||||
|
|
||||||
|
The following definitions are important to understand when using InfluxDB:
|
||||||
|
|
||||||
|
- **Point**: Single data record identified by its _measurement, tag keys, tag values, field key, and timestamp_.
|
||||||
|
- **Series**: A group of points with the same _measurement, tag keys and values, and field key_.
|
||||||
|
- **Primary key**: Columns used to uniquely identify each row in a table.
|
||||||
|
Rows are uniquely identified by their _timestamp and tag set_.
|
||||||
|
|
||||||
|
##### Example InfluxDB query results
|
||||||
|
|
||||||
|
{{< influxdb/points-series-sql >}}
|
||||||
|
|
||||||
|
## Tools to use
|
||||||
|
|
||||||
|
Throughout this tutorial, there are multiple tools you can use to manage and
|
||||||
|
interact with your InfluxDB Cloud Dedicated cluster.
|
||||||
|
Examples are provided for each of the following:
|
||||||
|
|
||||||
|
<!-- TODO: Define tooling -->
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
#### InfluxDB client libraries
|
||||||
|
|
||||||
|
[InfluxDB v1 and v2 client libraries](/influxdb/cloud/api-guide/client-libraries/)
|
||||||
|
are language-specific clients that interact with the InfluxDB HTTP v1 and v2 API.
|
||||||
|
Examples for client libraries are not provided in this tutorial, but these can
|
||||||
|
be used to perform actions outlined in this tutorial.
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
|
## Authorization
|
||||||
|
|
||||||
|
**InfluxDB Cloud Dedicated requires authentication** using
|
||||||
|
[tokens](/influxdb/cloud-dedicated/security/tokens/).
|
||||||
|
|
||||||
|
There a two types of tokens:
|
||||||
|
|
||||||
|
- **Database token**: A token that grants read and write access to InfluxDB
|
||||||
|
databases.
|
||||||
|
- **Management token**: A short-lived (1 hour) [Auth0 token](#) used to
|
||||||
|
administer your InfluxDB Cloud Dedicated cluster.
|
||||||
|
These are generated by the `influxctl` and do not require any direct management.
|
||||||
|
Management tokens authorize a user to perform tasks related to:
|
||||||
|
|
||||||
|
- Account management
|
||||||
|
- Database management
|
||||||
|
- Database token management
|
||||||
|
- Pricing
|
||||||
|
<!-- - Infrastructure management -->
|
||||||
|
|
||||||
|
{{< page-nav next="/influxdb/cloud-dedicated/get-started/setup/" >}}
|
|
@ -0,0 +1,677 @@
|
||||||
|
---
|
||||||
|
title: Get started querying data
|
||||||
|
seotitle: Query data | Get started with InfluxDB Cloud Dedicated
|
||||||
|
list_title: Query data
|
||||||
|
description: >
|
||||||
|
Get started querying data in InfluxDB Cloud Dedicated by learning about SQL and
|
||||||
|
InfluxQL and using tools like InfluxDB client libraries and Flight SQL clients.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Query data
|
||||||
|
parent: Get started
|
||||||
|
identifier: get-started-query-data
|
||||||
|
weight: 102
|
||||||
|
metadata: [3 / 3]
|
||||||
|
related:
|
||||||
|
- /influxdb/cloud-dedicated/query-data/
|
||||||
|
- /influxdb/cloud-dedicated/query-data/sql/
|
||||||
|
---
|
||||||
|
|
||||||
|
InfluxDB Cloud Dedicated supports multiple query languages:
|
||||||
|
|
||||||
|
- **SQL**: Traditional SQL powered by the [Apache Arrow DataFusion](https://arrow.apache.org/datafusion/)
|
||||||
|
query engine. The supported SQL syntax is similar to PostgreSQL.
|
||||||
|
- **InfluxQL**: A SQL-like query language designed to query time series data from
|
||||||
|
InfluxDB.
|
||||||
|
|
||||||
|
This tutorial walks you through the fundamentals of querying data in InfluxDB and
|
||||||
|
**focuses on using SQL** to query your time series data.
|
||||||
|
The InfluxDB SQL implementation is built using [Arrow Flight SQL](https://arrow.apache.org/docs/format/FlightSql.html),
|
||||||
|
a protocol for interacting with SQL databases using the Arrow in-memory format and the
|
||||||
|
[Flight RPC](https://arrow.apache.org/docs/format/Flight.html) framework.
|
||||||
|
It leverages the performance of [Apache Arrow](https://arrow.apache.org/) with
|
||||||
|
the simplicity of SQL.
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
The examples in this section of the tutorial query the
|
||||||
|
[**get-started** database](/influxdb/cloud-dedicated/get-started/setup/#create-a-database) for data written in the
|
||||||
|
[Get started writing data](/influxdb/cloud-dedicated/get-started/write/#write-line-protocol-to-influxdb) section.
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
|
## Tools to execute queries
|
||||||
|
|
||||||
|
InfluxDB Cloud Dedicated supports many different tools for querying data, including:
|
||||||
|
|
||||||
|
{{< req type="key" text="Covered in this tutorial" color="magenta" >}}
|
||||||
|
|
||||||
|
- [Flight SQL clients](){{< req text="\* " color="magenta" >}}
|
||||||
|
- [InfluxDB client libraries](){{< req text="\* " color="magenta" >}}
|
||||||
|
- [InfluxDB v1 HTTP API](?t=InfluxDB+API#execute-a-sql-query)
|
||||||
|
- [Superset](https://superset.apache.org/)
|
||||||
|
- [Grafana](/influxdb/cloud-dedicated/query-data/tools/grafana/)
|
||||||
|
- [Chronograf](/{{< latest "Chronograf" >}}/)
|
||||||
|
|
||||||
|
## SQL query basics
|
||||||
|
|
||||||
|
InfluxDB Cloud's SQL implementation is powered by the [Apache Arrow DataFusion](https://arrow.apache.org/datafusion/)
|
||||||
|
query engine which provides a SQL syntax similar to PostgreSQL.
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
This is a brief introduction to writing SQL queries for InfluxDB.
|
||||||
|
For more in-depth details, see [Query data with SQL](/influxdb/cloud-dedicated/query-data/sql/).
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
|
InfluxDB SQL queries most commonly include the following clauses:
|
||||||
|
|
||||||
|
{{< req type="key" >}}
|
||||||
|
|
||||||
|
- {{< req "\*">}} `SELECT`: Identify specific fields and tags to query from a
|
||||||
|
measurement or use the wild card alias (`*`) to select all fields and tags
|
||||||
|
from a measurement.
|
||||||
|
- {{< req "\*">}} `FROM`: Identify the measurement to query.
|
||||||
|
If coming from a SQL background, an InfluxDB measurement is the equivalent
|
||||||
|
of a relational table.
|
||||||
|
- `WHERE`: Only return data that meets defined conditions such as falling within
|
||||||
|
a time range, containing specific tag values, etc.
|
||||||
|
- `GROUP BY`: Group data into SQL partitions and apply an aggregate or selector
|
||||||
|
function to each group.
|
||||||
|
|
||||||
|
{{% influxdb/custom-timestamps %}}
|
||||||
|
```sql
|
||||||
|
-- Return the average temperature and humidity within time bounds from each room
|
||||||
|
SELECT
|
||||||
|
avg(temp),
|
||||||
|
avg(hum),
|
||||||
|
room
|
||||||
|
FROM
|
||||||
|
home
|
||||||
|
WHERE
|
||||||
|
time >= '2022-01-01T08:00:00Z'
|
||||||
|
AND time <= '2022-01-01T20:00:00Z'
|
||||||
|
GROUP BY
|
||||||
|
room
|
||||||
|
```
|
||||||
|
{{% /influxdb/custom-timestamps %}}
|
||||||
|
|
||||||
|
##### Example SQL queries
|
||||||
|
|
||||||
|
{{< expand-wrapper >}}
|
||||||
|
{{% expand "Select all data in a measurement" %}}
|
||||||
|
```sql
|
||||||
|
SELECT * FROM measurement
|
||||||
|
```
|
||||||
|
{{% /expand %}}
|
||||||
|
|
||||||
|
{{% expand "Select all data in a measurement within time bounds" %}}
|
||||||
|
```sql
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
home
|
||||||
|
WHERE
|
||||||
|
time >= '2022-01-01T08:00:00Z'
|
||||||
|
AND time <= '2022-01-01T20:00:00Z'
|
||||||
|
```
|
||||||
|
{{% /expand %}}
|
||||||
|
|
||||||
|
{{% expand "Select a specific field within relative time bounds" %}}
|
||||||
|
```sql
|
||||||
|
SELECT temp FROM home WHERE time >= now() - INTERVAL '1 day'
|
||||||
|
```
|
||||||
|
{{% /expand %}}
|
||||||
|
|
||||||
|
{{% expand "Select specific fields and tags from a measurement" %}}
|
||||||
|
```sql
|
||||||
|
SELECT temp, room FROM home
|
||||||
|
```
|
||||||
|
{{% /expand %}}
|
||||||
|
|
||||||
|
{{% expand "Select data based on tag value" %}}
|
||||||
|
```sql
|
||||||
|
SELECT * FROM home WHERE room = 'Kitchen'
|
||||||
|
```
|
||||||
|
{{% /expand %}}
|
||||||
|
|
||||||
|
{{% expand "Select data based on tag value within time bounds" %}}
|
||||||
|
```sql
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
home
|
||||||
|
WHERE
|
||||||
|
time >= '2022-01-01T08:00:00Z'
|
||||||
|
AND time <= '2022-01-01T20:00:00Z'
|
||||||
|
AND room = 'Living Room'
|
||||||
|
```
|
||||||
|
{{% /expand %}}
|
||||||
|
|
||||||
|
{{% expand "Downsample data by applying interval-based aggregates" %}}
|
||||||
|
```sql
|
||||||
|
SELECT
|
||||||
|
DATE_BIN(INTERVAL '1 hour', time, '2022-01-01T00:00:00Z'::TIMESTAMP) as _time,
|
||||||
|
room
|
||||||
|
selector_max(temp, time)['value'] AS 'max temp',
|
||||||
|
FROM
|
||||||
|
home
|
||||||
|
GROUP BY
|
||||||
|
_time,
|
||||||
|
'max temp',
|
||||||
|
room
|
||||||
|
ORDER BY room, _time
|
||||||
|
```
|
||||||
|
{{% /expand %}}
|
||||||
|
{{< /expand-wrapper >}}
|
||||||
|
|
||||||
|
### Execute a SQL query
|
||||||
|
|
||||||
|
Use the **InfluxDB UI**, **`influx` CLI**, or **InfluxDB API** to execute SQL queries.
|
||||||
|
For this example, use the following query to select all the data written to the
|
||||||
|
**get-started** bucket between
|
||||||
|
{{% influxdb/custom-timestamps-span %}}
|
||||||
|
**2022-01-01T08:00:00Z** and **2022-01-01T20:00:00Z**.
|
||||||
|
{{% /influxdb/custom-timestamps-span %}}
|
||||||
|
|
||||||
|
{{% influxdb/custom-timestamps %}}
|
||||||
|
```sql
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
home
|
||||||
|
WHERE
|
||||||
|
time >= '2022-01-01T08:00:00Z'
|
||||||
|
AND time <= '2022-01-01T20:00:00Z'
|
||||||
|
```
|
||||||
|
{{% /influxdb/custom-timestamps %}}
|
||||||
|
|
||||||
|
{{< tabs-wrapper >}}
|
||||||
|
{{% tabs %}}
|
||||||
|
[Python](#)
|
||||||
|
[Go](#)
|
||||||
|
{{% /tabs %}}
|
||||||
|
|
||||||
|
{{% tab-content %}}
|
||||||
|
<!--------------------------- BEGIN PYTHON CONTENT ---------------------------->
|
||||||
|
|
||||||
|
To query data from InfluxDB Cloud Dedicated using Python, use the
|
||||||
|
[`pyinflux3` module](https://github.com/InfluxCommunity/pyinflux3).
|
||||||
|
The following steps include setting up a Python virtual environment already
|
||||||
|
covered in [Get started writing data](/influxdb/cloud-dedicated/get-started/write/?t=Python#write-line-protocol-to-influxdb).
|
||||||
|
_If your projects virtual environment is already running, skip to step 3._
|
||||||
|
|
||||||
|
1. Setup your Python virtual environment.
|
||||||
|
Inside of your project directory:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python -m venv envs/virtual-env
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Activate the virtual environment.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
source ./envs/virtual-env/bin/activate
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Install the following dependencies:
|
||||||
|
|
||||||
|
{{< req type="key" text="Already installed in the [Write data section](/influxdb/cloud-dedicated/get-started/write/?t=Python#write-line-protocol-to-influxdb)" color="magenta" >}}
|
||||||
|
|
||||||
|
- `pyarrow` {{< req text="\*" color="magenta" >}}
|
||||||
|
- `flightsql-dbapi` {{< req text="\*" color="magenta" >}}
|
||||||
|
- `pyinflux3` {{< req text="\*" color="magenta" >}}
|
||||||
|
- `pandas`
|
||||||
|
- `tabulate` _(to return formatted tables)_
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pip install pandas tabulate
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Build your python script to query your InfluxDB database.
|
||||||
|
_These can be structured as a Python script or executed in a `python` shell._
|
||||||
|
|
||||||
|
1. Import the `InfluxDBClient3` constructor from the `influxdb_client_3` module.
|
||||||
|
|
||||||
|
2. Use the `InfluxDBClient3` constructor to instantiate an InfluxDB Client.
|
||||||
|
The example below assigns it to the `client` variable.
|
||||||
|
Provide the following credentials:
|
||||||
|
|
||||||
|
- **host**: InfluxDB Cloud Dedicated cluster URL (without protocol or trailing slash)
|
||||||
|
- **token**: Database token with read access to the specified database
|
||||||
|
- **database**: Database name to query
|
||||||
|
|
||||||
|
3. Provide the SQL query to execute. In the example below, it's assigned
|
||||||
|
to the `query`variable.
|
||||||
|
|
||||||
|
4. Use the `client.query` method to query data in the **get-started**
|
||||||
|
database and return an Arrow table. Assign the return value to the
|
||||||
|
`table` variable. Provide the following:
|
||||||
|
|
||||||
|
- **sql_query** SQL query string to execute
|
||||||
|
|
||||||
|
5. Use [`read_all`](https://docs.python.org/3/library/telnetlib.html#telnetlib.Telnet.read_all)
|
||||||
|
to read the data from InfluxDB and return an Arrow table.
|
||||||
|
|
||||||
|
6. Use [`to_pandas`](https://arrow.apache.org/docs/python/generated/pyarrow.Table.html#pyarrow.Table.to_pandas)
|
||||||
|
to convert the Arrow table to a pandas DataFrame.
|
||||||
|
|
||||||
|
7. Use [`to_markdown`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_markdown.html)
|
||||||
|
to convert the DataFrame to a markdown table.
|
||||||
|
|
||||||
|
8. Use `print` to print out the markdown table.
|
||||||
|
|
||||||
|
{{% influxdb/custom-timestamps %}}
|
||||||
|
|
||||||
|
```py
|
||||||
|
from influxdb_client_3 import InfluxDBClient3
|
||||||
|
|
||||||
|
client = InfluxDBClient3(
|
||||||
|
host="cluster-id.influxdb.io",
|
||||||
|
token="DATABASE_TOKEN",
|
||||||
|
database="get-started",
|
||||||
|
)
|
||||||
|
|
||||||
|
sql = '''
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
home
|
||||||
|
WHERE
|
||||||
|
time >= '2022-01-01T08:00:00Z'
|
||||||
|
AND time <= '2022-01-01T20:00:00Z'
|
||||||
|
'''
|
||||||
|
|
||||||
|
table = client.query(sql_query=sql)
|
||||||
|
reader = table.read_all()
|
||||||
|
print(reader.to_pandas().to_markdown())
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /influxdb/custom-timestamps %}}
|
||||||
|
|
||||||
|
{{< expand-wrapper >}}
|
||||||
|
{{% expand "View returned markdown table" %}}
|
||||||
|
{{% influxdb/custom-timestamps %}}
|
||||||
|
|
||||||
|
| | co | hum | room | temp | time |
|
||||||
|
|---:|-----:|------:|:------------|-------:|:--------------------|
|
||||||
|
| 0 | 0 | 35.9 | Kitchen | 21 | 2022-01-01 08:00:00 |
|
||||||
|
| 1 | 0 | 36.2 | Kitchen | 23 | 2022-01-01 09:00:00 |
|
||||||
|
| 2 | 0 | 36.1 | Kitchen | 22.7 | 2022-01-01 10:00:00 |
|
||||||
|
| 3 | 0 | 36 | Kitchen | 22.4 | 2022-01-01 11:00:00 |
|
||||||
|
| 4 | 0 | 36 | Kitchen | 22.5 | 2022-01-01 12:00:00 |
|
||||||
|
| 5 | 1 | 36.5 | Kitchen | 22.8 | 2022-01-01 13:00:00 |
|
||||||
|
| 6 | 1 | 36.3 | Kitchen | 22.8 | 2022-01-01 14:00:00 |
|
||||||
|
| 7 | 3 | 36.2 | Kitchen | 22.7 | 2022-01-01 15:00:00 |
|
||||||
|
| 8 | 7 | 36 | Kitchen | 22.4 | 2022-01-01 16:00:00 |
|
||||||
|
| 9 | 9 | 36 | Kitchen | 22.7 | 2022-01-01 17:00:00 |
|
||||||
|
| 10 | 18 | 36.9 | Kitchen | 23.3 | 2022-01-01 18:00:00 |
|
||||||
|
| 11 | 22 | 36.6 | Kitchen | 23.1 | 2022-01-01 19:00:00 |
|
||||||
|
| 12 | 26 | 36.5 | Kitchen | 22.7 | 2022-01-01 20:00:00 |
|
||||||
|
| 13 | 0 | 35.9 | Living Room | 21.1 | 2022-01-01 08:00:00 |
|
||||||
|
| 14 | 0 | 35.9 | Living Room | 21.4 | 2022-01-01 09:00:00 |
|
||||||
|
| 15 | 0 | 36 | Living Room | 21.8 | 2022-01-01 10:00:00 |
|
||||||
|
| 16 | 0 | 36 | Living Room | 22.2 | 2022-01-01 11:00:00 |
|
||||||
|
| 17 | 0 | 35.9 | Living Room | 22.2 | 2022-01-01 12:00:00 |
|
||||||
|
| 18 | 0 | 36 | Living Room | 22.4 | 2022-01-01 13:00:00 |
|
||||||
|
| 19 | 0 | 36.1 | Living Room | 22.3 | 2022-01-01 14:00:00 |
|
||||||
|
| 20 | 1 | 36.1 | Living Room | 22.3 | 2022-01-01 15:00:00 |
|
||||||
|
| 21 | 4 | 36 | Living Room | 22.4 | 2022-01-01 16:00:00 |
|
||||||
|
| 22 | 5 | 35.9 | Living Room | 22.6 | 2022-01-01 17:00:00 |
|
||||||
|
| 23 | 9 | 36.2 | Living Room | 22.8 | 2022-01-01 18:00:00 |
|
||||||
|
| 24 | 14 | 36.3 | Living Room | 22.5 | 2022-01-01 19:00:00 |
|
||||||
|
| 25 | 17 | 36.4 | Living Room | 22.2 | 2022-01-01 20:00:00 |
|
||||||
|
|
||||||
|
{{% /influxdb/custom-timestamps %}}
|
||||||
|
{{% /expand %}}
|
||||||
|
{{< /expand-wrapper >}}
|
||||||
|
|
||||||
|
<!---------------------------- END PYTHON CONTENT ----------------------------->
|
||||||
|
{{% /tab-content %}}
|
||||||
|
{{% tab-content %}}
|
||||||
|
<!----------------------------- BEGIN GO CONTENT ------------------------------>
|
||||||
|
|
||||||
|
1. In the `influxdb_go_client` directory you created in the
|
||||||
|
[Write data section](/influxdb/cloud-dedicated/get-started/write/?t=Go#write-line-protocol-to-influxdb),
|
||||||
|
create a new file named `query.go`.
|
||||||
|
|
||||||
|
2. In `query.go`:
|
||||||
|
|
||||||
|
1. Import the following packages:
|
||||||
|
|
||||||
|
- `context`
|
||||||
|
- `crypto/x509`
|
||||||
|
- `encoding/json`
|
||||||
|
- `fmt`
|
||||||
|
- `os`
|
||||||
|
- `github.com/apache/arrow/go/v12/arrow/flight/flightsql`
|
||||||
|
- `google.golang.org/grpc`
|
||||||
|
- `google.golang.org/grpc/credentials`
|
||||||
|
- `google.golang.org/grpc/metadata`
|
||||||
|
|
||||||
|
2. Create a `dbQuery` function. In `dbQuery, define the following
|
||||||
|
variables:
|
||||||
|
|
||||||
|
- **url**: InfluxDB Cloud Dedicated cluster URL _(no protocol, include port `443`)_
|
||||||
|
- **token**: [Database token](/influxdb/cloud-dedicated/admin/tokens/) with
|
||||||
|
read access to the **get-started** database.
|
||||||
|
_For security reasons, we recommend setting this as an environment
|
||||||
|
variable rather than including the raw token string._
|
||||||
|
- **database**: Database name to query
|
||||||
|
|
||||||
|
3. In the `dbQuery` function, create a gRPC transport to use to communicate
|
||||||
|
with your InfluxDB Cloud Dedicated cluster over the gRPC protocol.
|
||||||
|
|
||||||
|
4. Use `flightsql.NewClient` to create a new Flight SQL client.
|
||||||
|
|
||||||
|
5. Append the following key-value pairs to the outgoing context:
|
||||||
|
|
||||||
|
- **authorization**: Bearer <INFLUX_TOKEN>
|
||||||
|
- **database-name**: Database name
|
||||||
|
|
||||||
|
6. Define the query to execute.
|
||||||
|
|
||||||
|
7. Create a reader to read the Arrow table returned by the query and print
|
||||||
|
the results as JSON.
|
||||||
|
|
||||||
|
8. Create a `main` function that executes the `dbQuery` function.
|
||||||
|
|
||||||
|
{{% influxdb/custom-timestamps %}}
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"crypto/x509"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/apache/arrow/go/v12/arrow/flight/flightsql"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/grpc/credentials"
|
||||||
|
"google.golang.org/grpc/metadata"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dbQuery(ctx context.Context) error {
|
||||||
|
url := "cluster-id.influxdb.io:443"
|
||||||
|
token := os.Getenv("INFLUX_TOKEN")
|
||||||
|
database := "get-started"
|
||||||
|
|
||||||
|
// Create a gRPC transport
|
||||||
|
pool, err := x509.SystemCertPool()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("x509: %s", err)
|
||||||
|
}
|
||||||
|
transport := grpc.WithTransportCredentials(credentials.NewClientTLSFromCert(pool, ""))
|
||||||
|
opts := []grpc.DialOption{
|
||||||
|
transport,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create query client
|
||||||
|
client, err := flightsql.NewClient(url, nil, nil, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("flightsql: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx = metadata.AppendToOutgoingContext(ctx, "authorization", "Bearer "+token)
|
||||||
|
ctx = metadata.AppendToOutgoingContext(ctx, "iox-namespace-name", database)
|
||||||
|
|
||||||
|
// Execute query
|
||||||
|
query := `SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
home
|
||||||
|
WHERE
|
||||||
|
time >= '2022-01-01T08:00:00Z'
|
||||||
|
AND time <= '2022-01-01T20:00:00Z'`
|
||||||
|
|
||||||
|
info, err := client.Execute(ctx, query)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("flightsql flight info: %s", err)
|
||||||
|
}
|
||||||
|
reader, err := client.DoGet(ctx, info.Endpoint[0].Ticket)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("flightsql do get: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print results as JSON
|
||||||
|
for reader.Next() {
|
||||||
|
record := reader.Record()
|
||||||
|
b, err := json.MarshalIndent(record, "", " ")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Println("RECORD BATCH")
|
||||||
|
fmt.Println(string(b))
|
||||||
|
|
||||||
|
if err := reader.Err(); err != nil {
|
||||||
|
return fmt.Errorf("flightsql reader: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
if err := dbQuery(context.Background()); err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /influxdb/custom-timestamps %}}
|
||||||
|
|
||||||
|
Install all the necessary packages and run the program to write the line
|
||||||
|
protocol to your InfluxDB Cloud Dedicated cluster.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
go get ./...
|
||||||
|
go run ./query.go
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< expand-wrapper >}}
|
||||||
|
{{% expand "View program output" %}}
|
||||||
|
{{% influxdb/custom-timestamps %}}
|
||||||
|
|
||||||
|
```json
|
||||||
|
RECORD BATCH
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"co": 0,
|
||||||
|
"hum": 35.9,
|
||||||
|
"room": "Kitchen",
|
||||||
|
"temp": 21,
|
||||||
|
"time": "2022-01-01 08:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 0,
|
||||||
|
"hum": 36.2,
|
||||||
|
"room": "Kitchen",
|
||||||
|
"temp": 23,
|
||||||
|
"time": "2022-01-01 09:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 0,
|
||||||
|
"hum": 36.1,
|
||||||
|
"room": "Kitchen",
|
||||||
|
"temp": 22.7,
|
||||||
|
"time": "2022-01-01 10:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 0,
|
||||||
|
"hum": 36,
|
||||||
|
"room": "Kitchen",
|
||||||
|
"temp": 22.4,
|
||||||
|
"time": "2022-01-01 11:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 0,
|
||||||
|
"hum": 36,
|
||||||
|
"room": "Kitchen",
|
||||||
|
"temp": 22.5,
|
||||||
|
"time": "2022-01-01 12:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 1,
|
||||||
|
"hum": 36.5,
|
||||||
|
"room": "Kitchen",
|
||||||
|
"temp": 22.8,
|
||||||
|
"time": "2022-01-01 13:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 1,
|
||||||
|
"hum": 36.3,
|
||||||
|
"room": "Kitchen",
|
||||||
|
"temp": 22.8,
|
||||||
|
"time": "2022-01-01 14:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 3,
|
||||||
|
"hum": 36.2,
|
||||||
|
"room": "Kitchen",
|
||||||
|
"temp": 22.7,
|
||||||
|
"time": "2022-01-01 15:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 7,
|
||||||
|
"hum": 36,
|
||||||
|
"room": "Kitchen",
|
||||||
|
"temp": 22.4,
|
||||||
|
"time": "2022-01-01 16:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 9,
|
||||||
|
"hum": 36,
|
||||||
|
"room": "Kitchen",
|
||||||
|
"temp": 22.7,
|
||||||
|
"time": "2022-01-01 17:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 18,
|
||||||
|
"hum": 36.9,
|
||||||
|
"room": "Kitchen",
|
||||||
|
"temp": 23.3,
|
||||||
|
"time": "2022-01-01 18:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 22,
|
||||||
|
"hum": 36.6,
|
||||||
|
"room": "Kitchen",
|
||||||
|
"temp": 23.1,
|
||||||
|
"time": "2022-01-01 19:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 26,
|
||||||
|
"hum": 36.5,
|
||||||
|
"room": "Kitchen",
|
||||||
|
"temp": 22.7,
|
||||||
|
"time": "2022-01-01 20:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 0,
|
||||||
|
"hum": 35.9,
|
||||||
|
"room": "Living Room",
|
||||||
|
"temp": 21.1,
|
||||||
|
"time": "2022-01-01 08:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 0,
|
||||||
|
"hum": 35.9,
|
||||||
|
"room": "Living Room",
|
||||||
|
"temp": 21.4,
|
||||||
|
"time": "2022-01-01 09:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 0,
|
||||||
|
"hum": 36,
|
||||||
|
"room": "Living Room",
|
||||||
|
"temp": 21.8,
|
||||||
|
"time": "2022-01-01 10:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 0,
|
||||||
|
"hum": 36,
|
||||||
|
"room": "Living Room",
|
||||||
|
"temp": 22.2,
|
||||||
|
"time": "2022-01-01 11:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 0,
|
||||||
|
"hum": 35.9,
|
||||||
|
"room": "Living Room",
|
||||||
|
"temp": 22.2,
|
||||||
|
"time": "2022-01-01 12:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 0,
|
||||||
|
"hum": 36,
|
||||||
|
"room": "Living Room",
|
||||||
|
"temp": 22.4,
|
||||||
|
"time": "2022-01-01 13:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 0,
|
||||||
|
"hum": 36.1,
|
||||||
|
"room": "Living Room",
|
||||||
|
"temp": 22.3,
|
||||||
|
"time": "2022-01-01 14:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 1,
|
||||||
|
"hum": 36.1,
|
||||||
|
"room": "Living Room",
|
||||||
|
"temp": 22.3,
|
||||||
|
"time": "2022-01-01 15:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 4,
|
||||||
|
"hum": 36,
|
||||||
|
"room": "Living Room",
|
||||||
|
"temp": 22.4,
|
||||||
|
"time": "2022-01-01 16:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 5,
|
||||||
|
"hum": 35.9,
|
||||||
|
"room": "Living Room",
|
||||||
|
"temp": 22.6,
|
||||||
|
"time": "2022-01-01 17:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 9,
|
||||||
|
"hum": 36.2,
|
||||||
|
"room": "Living Room",
|
||||||
|
"temp": 22.8,
|
||||||
|
"time": "2022-01-01 18:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 14,
|
||||||
|
"hum": 36.3,
|
||||||
|
"room": "Living Room",
|
||||||
|
"temp": 22.5,
|
||||||
|
"time": "2022-01-01 19:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"co": 17,
|
||||||
|
"hum": 36.4,
|
||||||
|
"room": "Living Room",
|
||||||
|
"temp": 22.2,
|
||||||
|
"time": "2022-01-01 20:00:00"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /influxdb/custom-timestamps %}}
|
||||||
|
{{% /expand %}}
|
||||||
|
{{< /expand-wrapper >}}
|
||||||
|
|
||||||
|
<!------------------------------ END GO CONTENT ------------------------------->
|
||||||
|
{{% /tab-content %}}
|
||||||
|
{{< /tabs-wrapper >}}
|
||||||
|
|
||||||
|
**Congratulations!** You've learned the basics of querying data in InfluxDB
|
||||||
|
Cloud Dedicated with SQL.
|
||||||
|
For a deep dive into all the ways you can query InfluxDB, see the
|
||||||
|
[Query data in InfluxDB](/influxdb/cloud-dedicated/query-data/) section of documentation.
|
||||||
|
|
||||||
|
{{< page-nav prev="/influxdb/cloud-dedicated/get-started/write/" keepTab=true >}}
|
|
@ -0,0 +1,120 @@
|
||||||
|
---
|
||||||
|
title: Set up InfluxDB Cloud Dedicated
|
||||||
|
seotitle: Set up InfluxDB | Get started with InfluxDB Cloud Dedicated
|
||||||
|
list_title: Set up InfluxDB
|
||||||
|
description: >
|
||||||
|
Learn how to set up InfluxDB Cloud Dedicated for the "Get started with InfluxDB"
|
||||||
|
tutorial and for general use.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Set up InfluxDB
|
||||||
|
parent: Get started
|
||||||
|
identifier: get-started-set-up
|
||||||
|
weight: 101
|
||||||
|
metadata: [1 / 3]
|
||||||
|
related:
|
||||||
|
- /influxdb/cloud-dedicated/admin/buckets/
|
||||||
|
- /influxdb/cloud-dedicated/reference/cli/influx/
|
||||||
|
- /influxdb/cloud-dedicated/reference/api/
|
||||||
|
---
|
||||||
|
|
||||||
|
As you get started with this tutorial, do the following to make sure everything
|
||||||
|
you need is in place.
|
||||||
|
|
||||||
|
- [Request an InfluxDB Cloud Dedicated cluster](#request-an-influxdb-cloud-dedicated-cluster)
|
||||||
|
- [Download, install, and configure the influxctl CLI](#download-install-and-configure-the-influxctl-cli)
|
||||||
|
- [Create a database](#create-a-database)
|
||||||
|
- [Create a database token](#create-a-database-token)
|
||||||
|
|
||||||
|
## Request an InfluxDB Cloud Dedicated cluster
|
||||||
|
|
||||||
|
[Contact the InfluxData Sales team]({{< dedicated-link >}}) to request an
|
||||||
|
InfluxDB Cloud Dedicated cluster.
|
||||||
|
When your cluster is deployed, your InfluxData account representative provides
|
||||||
|
the following:
|
||||||
|
|
||||||
|
- An **Auth0 login** to authenticate access to your cluster
|
||||||
|
- Your InfluxDB Cloud Dedicated **account ID**
|
||||||
|
- Your InfluxDB Cloud Dedicated **cluster ID**
|
||||||
|
- Your InfluxDB Cloud Dedicated **cluster URL**
|
||||||
|
|
||||||
|
## Download, install, and configure the influxctl CLI
|
||||||
|
|
||||||
|
The [`influxctl` CLI](/influxdb/cloud-dedicated/reference/cli/influxctl/)
|
||||||
|
provides a simple way to manage your InfluxDB Cloud Dedicated cluster from a
|
||||||
|
command line. It lets you perform administrative tasks such as managing
|
||||||
|
databases and tokens.
|
||||||
|
|
||||||
|
1. **Download the `influxctl` CLI**.
|
||||||
|
|
||||||
|
_Contact your InfluxData account representative for information about
|
||||||
|
downloading and installing the `influxctl` CLI._
|
||||||
|
|
||||||
|
2. **Create a connection profile and provide your InfluxDB Cloud Dedicated connection credentials**.
|
||||||
|
The `influxctl` CLI uses [connection profiles](/influxdb/cloud-dedicated/reference/cli/influxctl/#configure-connection-profiles)
|
||||||
|
to connect to and authenticate with your InfluxDB Cloud Dedicated cluster.
|
||||||
|
|
||||||
|
To create a connection profile, run `influxctl init` to start an interactive
|
||||||
|
prompt that creates and stores a connection profile.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl init
|
||||||
|
```
|
||||||
|
|
||||||
|
Provide the following required credentials:
|
||||||
|
|
||||||
|
- Account ID
|
||||||
|
- Cluster ID
|
||||||
|
|
||||||
|
_For more information about `influxctl` profiles, see
|
||||||
|
[Configure connection profiles](/influxdb/cloud-dedicated/reference/cli/influxctl/#configure-connection-profiles)_.
|
||||||
|
|
||||||
|
## Create a database
|
||||||
|
|
||||||
|
Use the [`influxctl database create` command](/influxdb/cloud-dedicated/reference/cli/influxctl/database/create/)
|
||||||
|
to create a database. You can use an existing database or create a new one
|
||||||
|
specifically for this getting started tutorial.
|
||||||
|
_Examples in this getting started tutorial assume a database named **"get-started"**._
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
#### Authenticate with your cluster
|
||||||
|
|
||||||
|
The first time you run an `influxctl` CLI command, you are directed
|
||||||
|
to login to **Auth0**. Once logged in, Auth0 issues a short-lived (1 hour)
|
||||||
|
management token for the `influxctl` CLI that grants administrative access
|
||||||
|
to your InfluxDB Cloud Dedicated cluster.
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
|
Provide the following:
|
||||||
|
|
||||||
|
- Database name.
|
||||||
|
- _(Optional)_ Database [retention period](/influxdb/cloud-dedicated/admin/databases/#retention-periods)
|
||||||
|
as a duration value.
|
||||||
|
If no retention period is specified, the default is infinite.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl database create \
|
||||||
|
--retention-period 1y \
|
||||||
|
get-started
|
||||||
|
```
|
||||||
|
|
||||||
|
## Create a database token
|
||||||
|
|
||||||
|
Use the [`influxctl token create` command](/influxdb/cloud-dedicated/reference/cli/influxctl/token/create/)
|
||||||
|
to create a database token with read and write permissions for your database.
|
||||||
|
|
||||||
|
Provide the following:
|
||||||
|
|
||||||
|
- Permission grants
|
||||||
|
- `--read-database`: Grants read access to a database
|
||||||
|
- `--write-database` Grants write access to a database
|
||||||
|
- Token description
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token create \
|
||||||
|
--read-database get-started \
|
||||||
|
--write-database get-started \
|
||||||
|
"Read/write token for get-started database"
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< page-nav prev="/influxdb/cloud-dedicated/get-started/" next="/influxdb/cloud-dedicated/get-started/write/" keepTab=true >}}
|
|
@ -0,0 +1,519 @@
|
||||||
|
---
|
||||||
|
title: Get started writing data
|
||||||
|
seotitle: Write data | Get started with InfluxDB Cloud Dedicated
|
||||||
|
list_title: Write data
|
||||||
|
description: >
|
||||||
|
Get started writing data to InfluxDB Cloud Dedicated by learning about line protocol
|
||||||
|
and using tools like the InfluxDB API and Telegraf.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Write data
|
||||||
|
parent: Get started
|
||||||
|
identifier: get-started-write-data
|
||||||
|
weight: 101
|
||||||
|
metadata: [2 / 3]
|
||||||
|
related:
|
||||||
|
- /influxdb/cloud-dedicated/write-data/
|
||||||
|
- /influxdb/cloud-dedicated/write-data/best-practices/
|
||||||
|
- /influxdb/cloud-dedicated/reference/syntax/line-protocol/
|
||||||
|
- /{{< latest "telegraf" >}}/
|
||||||
|
---
|
||||||
|
|
||||||
|
InfluxDB provides many different options for ingesting or writing data, including
|
||||||
|
the following:
|
||||||
|
|
||||||
|
- [InfluxDB HTTP API (v1 and v2)](/influxdb/cloud-serverless/reference/api/)
|
||||||
|
- [`influx` CLI (v1 and v2)](/influxdb/cloud-dedicated/reference/cli/influx/)
|
||||||
|
- [Telegraf](/{{< latest "telegraf" >}}/)
|
||||||
|
- [InfluxDB client libraries](/influxdb/cloud-dedicated/api-guide/client-libraries/)
|
||||||
|
- etc.
|
||||||
|
|
||||||
|
This tutorial walks you through the fundamental of using **line protocol** to write
|
||||||
|
data to InfluxDB. If using tools like Telegraf or InfluxDB client libraries, they can
|
||||||
|
build the line protocol for you, but it's good to understand how line protocol works.
|
||||||
|
|
||||||
|
## Line protocol
|
||||||
|
|
||||||
|
All data written to InfluxDB is written using **line protocol**, a text-based
|
||||||
|
format that lets you provide the necessary information to write a data point to InfluxDB.
|
||||||
|
_This tutorial covers the basics of line protocol, but for detailed information,
|
||||||
|
see the [Line protocol reference](/influxdb/cloud-dedicated/reference/syntax/line-protocol/)._
|
||||||
|
|
||||||
|
### Line protocol elements
|
||||||
|
|
||||||
|
Each line of line protocol contains the following elements:
|
||||||
|
|
||||||
|
{{< req type="key" >}}
|
||||||
|
|
||||||
|
- {{< req "\*" >}} **measurement**: String that identifies the [measurement]() to store the data in.
|
||||||
|
- **tag set**: Comma-delimited list of key value pairs, each representing a tag.
|
||||||
|
Tag keys and values are unquoted strings. _Spaces, commas, and equal characters must be escaped._
|
||||||
|
- {{< req "\*" >}} **field set**: Comma-delimited list of key value pairs, each representing a field.
|
||||||
|
Field keys are unquoted strings. _Spaces and commas must be escaped._
|
||||||
|
Field values can be [strings](/influxdb/cloud-dedicated/reference/syntax/line-protocol/#string) (quoted),
|
||||||
|
[floats](/influxdb/cloud-dedicated/reference/syntax/line-protocol/#float),
|
||||||
|
[integers](/influxdb/cloud-dedicated/reference/syntax/line-protocol/#integer),
|
||||||
|
[unsigned integers](/influxdb/cloud-dedicated/reference/syntax/line-protocol/#uinteger),
|
||||||
|
or [booleans](/influxdb/cloud-dedicated/reference/syntax/line-protocol/#boolean).
|
||||||
|
- **timestamp**: [Unix timestamp](/influxdb/cloud-dedicated/reference/syntax/line-protocol/#unix-timestamp)
|
||||||
|
associated with the data. InfluxDB supports up to nanosecond precision.
|
||||||
|
_If the precision of the timestamp is not in nanoseconds, you must specify the
|
||||||
|
precision when writing the data to InfluxDB._
|
||||||
|
|
||||||
|
#### Line protocol element parsing
|
||||||
|
|
||||||
|
- **measurement**: Everything before the _first unescaped comma before the first whitespace_.
|
||||||
|
- **tag set**: Key-value pairs between the _first unescaped comma_ and the _first unescaped whitespace_.
|
||||||
|
- **field set**: Key-value pairs between the _first and second unescaped whitespaces_.
|
||||||
|
- **timestamp**: Integer value after the _second unescaped whitespace_.
|
||||||
|
- Lines are separated by the newline character (`\n`).
|
||||||
|
Line protocol is whitespace sensitive.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
{{< influxdb/line-protocol >}}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
_For schema design recommendations, see [InfluxDB schema design](/influxdb/cloud-iox/write-data/best-practices/schema-design/)._
|
||||||
|
|
||||||
|
## Construct line protocol
|
||||||
|
|
||||||
|
With a basic understanding of line protocol, you can now construct line protocol
|
||||||
|
and write data to InfluxDB.
|
||||||
|
Consider a use case where you collect data from sensors in your home.
|
||||||
|
Each sensor collects temperature, humidity, and carbon monoxide readings.
|
||||||
|
To collect this data, use the following schema:
|
||||||
|
|
||||||
|
- **measurement**: `home`
|
||||||
|
- **tags**
|
||||||
|
- `room`: Living Room or Kitchen
|
||||||
|
- **fields**
|
||||||
|
- `temp`: temperature in °C (float)
|
||||||
|
- `hum`: percent humidity (float)
|
||||||
|
- `co`: carbon monoxide in parts per million (integer)
|
||||||
|
- **timestamp**: Unix timestamp in _second_ precision
|
||||||
|
|
||||||
|
Data is collected hourly beginning at
|
||||||
|
{{% influxdb/custom-timestamps-span %}}**2022-01-01T08:00:00Z (UTC)** until **2022-01-01T20:00:00Z (UTC)**{{% /influxdb/custom-timestamps-span %}}.
|
||||||
|
The resulting line protocol would look something like the following:
|
||||||
|
|
||||||
|
{{% influxdb/custom-timestamps %}}
|
||||||
|
|
||||||
|
##### Home sensor data line protocol
|
||||||
|
|
||||||
|
```sh
|
||||||
|
home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1641024000
|
||||||
|
home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000
|
||||||
|
home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1641027600
|
||||||
|
home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600
|
||||||
|
home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1641031200
|
||||||
|
home,room=Kitchen temp=22.7,hum=36.1,co=0i 1641031200
|
||||||
|
home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1641034800
|
||||||
|
home,room=Kitchen temp=22.4,hum=36.0,co=0i 1641034800
|
||||||
|
home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1641038400
|
||||||
|
home,room=Kitchen temp=22.5,hum=36.0,co=0i 1641038400
|
||||||
|
home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1641042000
|
||||||
|
home,room=Kitchen temp=22.8,hum=36.5,co=1i 1641042000
|
||||||
|
home,room=Living\ Room temp=22.3,hum=36.1,co=0i 1641045600
|
||||||
|
home,room=Kitchen temp=22.8,hum=36.3,co=1i 1641045600
|
||||||
|
home,room=Living\ Room temp=22.3,hum=36.1,co=1i 1641049200
|
||||||
|
home,room=Kitchen temp=22.7,hum=36.2,co=3i 1641049200
|
||||||
|
home,room=Living\ Room temp=22.4,hum=36.0,co=4i 1641052800
|
||||||
|
home,room=Kitchen temp=22.4,hum=36.0,co=7i 1641052800
|
||||||
|
home,room=Living\ Room temp=22.6,hum=35.9,co=5i 1641056400
|
||||||
|
home,room=Kitchen temp=22.7,hum=36.0,co=9i 1641056400
|
||||||
|
home,room=Living\ Room temp=22.8,hum=36.2,co=9i 1641060000
|
||||||
|
home,room=Kitchen temp=23.3,hum=36.9,co=18i 1641060000
|
||||||
|
home,room=Living\ Room temp=22.5,hum=36.3,co=14i 1641063600
|
||||||
|
home,room=Kitchen temp=23.1,hum=36.6,co=22i 1641063600
|
||||||
|
home,room=Living\ Room temp=22.2,hum=36.4,co=17i 1641067200
|
||||||
|
home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /influxdb/custom-timestamps %}}
|
||||||
|
|
||||||
|
## Write line protocol to InfluxDB
|
||||||
|
|
||||||
|
Use the **InfluxDB v2 HTTP API** or **InfluxDB client libraries** to write the
|
||||||
|
line protocol above to InfluxDB.
|
||||||
|
The following examples show how to use the **Python** and **Go** client libraries to write line protocol.
|
||||||
|
|
||||||
|
{{< tabs-wrapper >}}
|
||||||
|
{{% tabs %}}
|
||||||
|
[InfluxDB API](#)
|
||||||
|
[Python](#)
|
||||||
|
[Go](#)
|
||||||
|
{{% /tabs %}}
|
||||||
|
|
||||||
|
{{% tab-content %}}
|
||||||
|
<!----------------------------- BEGIN API CONTENT ----------------------------->
|
||||||
|
|
||||||
|
To write data to InfluxDB Cloud Dedicated using the InfluxDB v2 HTTP API, send a
|
||||||
|
request to the InfluxDB API `/api/v2/write` endpoint using the `POST` request method.
|
||||||
|
|
||||||
|
{{< api-endpoint endpoint="https://cluster-id.influxdb.io/api/v2/write" method="post" api-ref="/influxdb/cloud-iox/api/#operation/PostWrite" >}}
|
||||||
|
|
||||||
|
Include the following with your request:
|
||||||
|
|
||||||
|
- **Headers**:
|
||||||
|
- **Authorization**: Bearer <INFLUX_TOKEN>
|
||||||
|
- **Content-Type**: text/plain; charset=utf-8
|
||||||
|
- **Accept**: application/json
|
||||||
|
- **Query parameters**:
|
||||||
|
- **bucket**: InfluxDB database name
|
||||||
|
- **precision**: Timestamp precision (default is `ns`)
|
||||||
|
- **Request body**: Line protocol as plain text
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
With the InfluxDB Cloud Dedicated v2 API `/api/v2/write` endpoint, `Authorization: Bearer` and `Authorization: Token` are equivalent and you can use either scheme to pass a database token in your request. For more information about HTTP API token schemes, see how to [authenticate API requests](/influxdb/cloud-dedicated/primers/api/v2/#authenticate-api-requests).
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
|
The following example uses cURL and the InfluxDB v2 API to write line protocol
|
||||||
|
to InfluxDB Cloud dedicated:
|
||||||
|
|
||||||
|
{{% influxdb/custom-timestamps %}}
|
||||||
|
```sh
|
||||||
|
export INFLUX_HOST=https://cluster-id.influxdb.io
|
||||||
|
export INFLUX_TOKEN=DATABASE_TOKEN
|
||||||
|
|
||||||
|
DATABASE_NAME=get-started
|
||||||
|
|
||||||
|
curl --request POST \
|
||||||
|
"$INFLUX_HOST/api/v2/write?bucket=$DATABASE_NAME&precision=s" \
|
||||||
|
--header "Authorization: Bearer $INFLUX_TOKEN" \
|
||||||
|
--header "Content-Type: text/plain; charset=utf-8" \
|
||||||
|
--header "Accept: application/json" \
|
||||||
|
--data-binary "
|
||||||
|
home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1641024000
|
||||||
|
home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000
|
||||||
|
home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1641027600
|
||||||
|
home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600
|
||||||
|
home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1641031200
|
||||||
|
home,room=Kitchen temp=22.7,hum=36.1,co=0i 1641031200
|
||||||
|
home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1641034800
|
||||||
|
home,room=Kitchen temp=22.4,hum=36.0,co=0i 1641034800
|
||||||
|
home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1641038400
|
||||||
|
home,room=Kitchen temp=22.5,hum=36.0,co=0i 1641038400
|
||||||
|
home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1641042000
|
||||||
|
home,room=Kitchen temp=22.8,hum=36.5,co=1i 1641042000
|
||||||
|
home,room=Living\ Room temp=22.3,hum=36.1,co=0i 1641045600
|
||||||
|
home,room=Kitchen temp=22.8,hum=36.3,co=1i 1641045600
|
||||||
|
home,room=Living\ Room temp=22.3,hum=36.1,co=1i 1641049200
|
||||||
|
home,room=Kitchen temp=22.7,hum=36.2,co=3i 1641049200
|
||||||
|
home,room=Living\ Room temp=22.4,hum=36.0,co=4i 1641052800
|
||||||
|
home,room=Kitchen temp=22.4,hum=36.0,co=7i 1641052800
|
||||||
|
home,room=Living\ Room temp=22.6,hum=35.9,co=5i 1641056400
|
||||||
|
home,room=Kitchen temp=22.7,hum=36.0,co=9i 1641056400
|
||||||
|
home,room=Living\ Room temp=22.8,hum=36.2,co=9i 1641060000
|
||||||
|
home,room=Kitchen temp=23.3,hum=36.9,co=18i 1641060000
|
||||||
|
home,room=Living\ Room temp=22.5,hum=36.3,co=14i 1641063600
|
||||||
|
home,room=Kitchen temp=23.1,hum=36.6,co=22i 1641063600
|
||||||
|
home,room=Living\ Room temp=22.2,hum=36.4,co=17i 1641067200
|
||||||
|
home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200
|
||||||
|
"
|
||||||
|
```
|
||||||
|
{{% /influxdb/custom-timestamps %}}
|
||||||
|
<!------------------------------ END API CONTENT ------------------------------>
|
||||||
|
{{% /tab-content %}}
|
||||||
|
{{% tab-content %}}
|
||||||
|
<!---------------------------- BEGIN PYTHON CONTENT --------------------------->
|
||||||
|
|
||||||
|
To write data to InfluxDB Cloud Dedicated using Python, use the
|
||||||
|
[`pyinflux3` module](https://github.com/InfluxCommunity/pyinflux3).
|
||||||
|
The following steps include setting up a Python virtual environment to scope
|
||||||
|
dependencies to your current project.
|
||||||
|
|
||||||
|
1. Setup your Python virtual environment.
|
||||||
|
Inside of your project directory:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python -m venv envs/virtual-env
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Activate the virtual environment.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
source ./envs/virtual-env/bin/activate
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Install the following dependencies:
|
||||||
|
|
||||||
|
- `pyarrow`
|
||||||
|
- `flightsql-dbapi`
|
||||||
|
- `pyinflux3`
|
||||||
|
|
||||||
|
```python
|
||||||
|
pip install pyarrow flightsql-dbapi pyinflux3
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Build your python script to write the [sample line protocol](#home-sensor-data-line-protocol)
|
||||||
|
to InfluxDB. _Save the script to a file and run `python SCRIPT_NAME` or run `python` to write and execute the script using the interactive shell._
|
||||||
|
|
||||||
|
1. Import the `InfluxDBClient3` object from the `influxdb_client_3` module.
|
||||||
|
2. Use the `InfluxDBClient3` constructor to instantiate an InfluxDB Client.
|
||||||
|
The example below assigns it to the `client` variable.
|
||||||
|
Provide the following credentials:
|
||||||
|
|
||||||
|
- **host**: InfluxDB Cloud Dedicated cluster URL (without protocol or trailing slash)
|
||||||
|
- **org**: _Leave as an empty string_ (InfluxDB Cloud Dedicated ignores `org`, but the client requires the parameter)
|
||||||
|
- **token**: Database token with write access to the target database
|
||||||
|
- **database**: Database name to write to
|
||||||
|
|
||||||
|
3. Use the `client.write` method to write the line protocol to the **get-started**
|
||||||
|
database. Provide the following:
|
||||||
|
|
||||||
|
- **Line protocol** as an array of strings where each element is an individual
|
||||||
|
line of line protocol.
|
||||||
|
- **`write_precision` option** to specify the timestamp precision as
|
||||||
|
seconds (`s`).
|
||||||
|
|
||||||
|
{{% influxdb/custom-timestamps %}}
|
||||||
|
|
||||||
|
```py
|
||||||
|
from influxdb_client_3 import InfluxDBClient3
|
||||||
|
|
||||||
|
client = InfluxDBClient3(
|
||||||
|
host="cluster-id.influxdb.io",
|
||||||
|
org="",
|
||||||
|
token="DATABASE_TOKEN",
|
||||||
|
database="get-started"
|
||||||
|
)
|
||||||
|
|
||||||
|
client.write([
|
||||||
|
"home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1641024000",
|
||||||
|
"home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000",
|
||||||
|
"home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1641027600",
|
||||||
|
"home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600",
|
||||||
|
"home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1641031200",
|
||||||
|
"home,room=Kitchen temp=22.7,hum=36.1,co=0i 1641031200",
|
||||||
|
"home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1641034800",
|
||||||
|
"home,room=Kitchen temp=22.4,hum=36.0,co=0i 1641034800",
|
||||||
|
"home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1641038400",
|
||||||
|
"home,room=Kitchen temp=22.5,hum=36.0,co=0i 1641038400",
|
||||||
|
"home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1641042000",
|
||||||
|
"home,room=Kitchen temp=22.8,hum=36.5,co=1i 1641042000",
|
||||||
|
"home,room=Living\ Room temp=22.3,hum=36.1,co=0i 1641045600",
|
||||||
|
"home,room=Kitchen temp=22.8,hum=36.3,co=1i 1641045600",
|
||||||
|
"home,room=Living\ Room temp=22.3,hum=36.1,co=1i 1641049200",
|
||||||
|
"home,room=Kitchen temp=22.7,hum=36.2,co=3i 1641049200",
|
||||||
|
"home,room=Living\ Room temp=22.4,hum=36.0,co=4i 1641052800",
|
||||||
|
"home,room=Kitchen temp=22.4,hum=36.0,co=7i 1641052800",
|
||||||
|
"home,room=Living\ Room temp=22.6,hum=35.9,co=5i 1641056400",
|
||||||
|
"home,room=Kitchen temp=22.7,hum=36.0,co=9i 1641056400",
|
||||||
|
"home,room=Living\ Room temp=22.8,hum=36.2,co=9i 1641060000",
|
||||||
|
"home,room=Kitchen temp=23.3,hum=36.9,co=18i 1641060000",
|
||||||
|
"home,room=Living\ Room temp=22.5,hum=36.3,co=14i 1641063600",
|
||||||
|
"home,room=Kitchen temp=23.1,hum=36.6,co=22i 1641063600",
|
||||||
|
"home,room=Living\ Room temp=22.2,hum=36.4,co=17i 1641067200",
|
||||||
|
"home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200"],
|
||||||
|
write_precision='s'
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /influxdb/custom-timestamps %}}
|
||||||
|
|
||||||
|
<!----------------------------- END PYTHON CONTENT ---------------------------->
|
||||||
|
{{% /tab-content %}}
|
||||||
|
{{% tab-content %}}
|
||||||
|
<!----------------------------- BEGIN GO CONTENT ------------------------------>
|
||||||
|
|
||||||
|
To write data to InfluxDB Cloud Dedicated using Go, use the
|
||||||
|
[influxdb-client-go module](https://github.com/influxdata/influxdb-client-go).
|
||||||
|
|
||||||
|
1. Create a new go module in your project directory.
|
||||||
|
|
||||||
|
1. Create a new module directory and navigate into it.
|
||||||
|
2. Initialize a new Go module in the current working directory.
|
||||||
|
3. Create a `write.go` file.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mkdir influxdb_go_client && cd $_
|
||||||
|
go mod init influxdb_go_client
|
||||||
|
touch write.go
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Inside of `write.go` instantiate an InfluxDB write client to write the
|
||||||
|
[line protocol above](#home-sensor-data-line-protocol) to InfluxDB.
|
||||||
|
|
||||||
|
1. Import the following packages
|
||||||
|
|
||||||
|
- `context`
|
||||||
|
- `fmt`
|
||||||
|
- `log`
|
||||||
|
- `os`
|
||||||
|
- `time`
|
||||||
|
- `github.com/influxdata/influxdb-client-go/v2` aliased as `influxdb2`
|
||||||
|
|
||||||
|
2. Create a `dbWrite` function.
|
||||||
|
3. In the `dbWrite` function, use `influxdb2.NewClientWithOptions` to
|
||||||
|
create a `writeClient` that accepts write options.
|
||||||
|
The write client requires the following credentials:
|
||||||
|
|
||||||
|
- **url**: InfluxDB Cloud Dedicated cluster URL
|
||||||
|
- **token**: [Database token](/influxdb/cloud-dedicated/admin/tokens/)
|
||||||
|
with write access to the **get-started** database.
|
||||||
|
_For security reasons, we recommend setting this as an environment
|
||||||
|
variable rather than including the raw token string._
|
||||||
|
|
||||||
|
Because the timestamps in the line protocol are in second
|
||||||
|
precision, **use `SetPrecision(time.Second)` to define the write precision option**.
|
||||||
|
|
||||||
|
4. Use `writeClient.WriteAPIBlocking` to define a `writeAPI`.
|
||||||
|
The write API requires the following credentials:
|
||||||
|
|
||||||
|
- **bucket**: InfluxDB database name.
|
||||||
|
|
||||||
|
5. Define an array of line protocol strings where each element is a single
|
||||||
|
line of line protocol.
|
||||||
|
|
||||||
|
6. Iterate through the array of line protocol and use `writeAPI.WriteRecord`
|
||||||
|
to write each line of line protocol to InfluxDB.
|
||||||
|
|
||||||
|
7. Define a `main` function that executes the `dbWrite` function.
|
||||||
|
|
||||||
|
{{% influxdb/custom-timestamps %}}
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dbWrite(ctx context.Context) error {
|
||||||
|
// Create write client
|
||||||
|
url := "https://cluster-id.influxdb.io"
|
||||||
|
token := os.Getenv("INFLUX_TOKEN")
|
||||||
|
writeClient := influxdb2.NewClientWithOptions(url, token, influxdb2.DefaultOptions().SetPrecision(time.Second))
|
||||||
|
|
||||||
|
// Define write API
|
||||||
|
org := "ignored"
|
||||||
|
bucket := "DATABASE_NAME"
|
||||||
|
writeAPI := writeClient.WriteAPIBlocking(org, bucket)
|
||||||
|
|
||||||
|
line := [...]string{
|
||||||
|
`home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1641024000`,
|
||||||
|
`home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000`,
|
||||||
|
`home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1641027600`,
|
||||||
|
`home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600`,
|
||||||
|
`home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1641031200`,
|
||||||
|
`home,room=Kitchen temp=22.7,hum=36.1,co=0i 1641031200`,
|
||||||
|
`home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1641034800`,
|
||||||
|
`home,room=Kitchen temp=22.4,hum=36.0,co=0i 1641034800`,
|
||||||
|
`home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1641038400`,
|
||||||
|
`home,room=Kitchen temp=22.5,hum=36.0,co=0i 1641038400`,
|
||||||
|
`home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1641042000`,
|
||||||
|
`home,room=Kitchen temp=22.8,hum=36.5,co=1i 1641042000`,
|
||||||
|
`home,room=Living\ Room temp=22.3,hum=36.1,co=0i 1641045600`,
|
||||||
|
`home,room=Kitchen temp=22.8,hum=36.3,co=1i 1641045600`,
|
||||||
|
`home,room=Living\ Room temp=22.3,hum=36.1,co=1i 1641049200`,
|
||||||
|
`home,room=Kitchen temp=22.7,hum=36.2,co=3i 1641049200`,
|
||||||
|
`home,room=Living\ Room temp=22.4,hum=36.0,co=4i 1641052800`,
|
||||||
|
`home,room=Kitchen temp=22.4,hum=36.0,co=7i 1641052800`,
|
||||||
|
`home,room=Living\ Room temp=22.6,hum=35.9,co=5i 1641056400`,
|
||||||
|
`home,room=Kitchen temp=22.7,hum=36.0,co=9i 1641056400`,
|
||||||
|
`home,room=Living\ Room temp=22.8,hum=36.2,co=9i 1641060000`,
|
||||||
|
`home,room=Kitchen temp=23.3,hum=36.9,co=18i 1641060000`,
|
||||||
|
`home,room=Living\ Room temp=22.5,hum=36.3,co=14i 1641063600`,
|
||||||
|
`home,room=Kitchen temp=23.1,hum=36.6,co=22i 1641063600`,
|
||||||
|
`home,room=Living\ Room temp=22.2,hum=36.4,co=17i 1641067200`,
|
||||||
|
`home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200`,
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, lp := range line {
|
||||||
|
err := writeAPI.WriteRecord(context.Background(), lp)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Error writing line protocol: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("Data has been written successfully.")
|
||||||
|
writeClient.Close()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
if err := dbWrite(context.Background()); err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace the following:
|
||||||
|
|
||||||
|
- **`DATABASE_NAME`**: your InfluxDB Cloud Dedicated database
|
||||||
|
- **`DATABASE_TOKEN`**: a [database token](/influxdb/cloud-dedicated/admin/tokens/) with sufficient permissions to the database
|
||||||
|
|
||||||
|
Run the following command to install the necessary packages:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
go get ./...
|
||||||
|
```
|
||||||
|
|
||||||
|
Run `write.go` to write the line protocol to your InfluxDB Cloud Dedicated cluster:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
go run ./write.go
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /influxdb/custom-timestamps %}}
|
||||||
|
|
||||||
|
<!------------------------------- END GO CONTENT ------------------------------>
|
||||||
|
{{% /tab-content %}}
|
||||||
|
{{< /tabs-wrapper >}}
|
||||||
|
|
||||||
|
{{< expand-wrapper >}}
|
||||||
|
{{% expand "View the written data" %}}
|
||||||
|
|
||||||
|
{{% influxdb/custom-timestamps %}}
|
||||||
|
| time | room | co | hum | temp |
|
||||||
|
| :------------------- | :---------- | --: | ---: | ---: |
|
||||||
|
| 2022-01-01T08:00:00Z | Kitchen | 0 | 35.9 | 21 |
|
||||||
|
| 2022-01-01T09:00:00Z | Kitchen | 0 | 36.2 | 23 |
|
||||||
|
| 2022-01-01T10:00:00Z | Kitchen | 0 | 36.1 | 22.7 |
|
||||||
|
| 2022-01-01T11:00:00Z | Kitchen | 0 | 36 | 22.4 |
|
||||||
|
| 2022-01-01T12:00:00Z | Kitchen | 0 | 36 | 22.5 |
|
||||||
|
| 2022-01-01T13:00:00Z | Kitchen | 1 | 36.5 | 22.8 |
|
||||||
|
| 2022-01-01T14:00:00Z | Kitchen | 1 | 36.3 | 22.8 |
|
||||||
|
| 2022-01-01T15:00:00Z | Kitchen | 3 | 36.2 | 22.7 |
|
||||||
|
| 2022-01-01T16:00:00Z | Kitchen | 7 | 36 | 22.4 |
|
||||||
|
| 2022-01-01T17:00:00Z | Kitchen | 9 | 36 | 22.7 |
|
||||||
|
| 2022-01-01T18:00:00Z | Kitchen | 18 | 36.9 | 23.3 |
|
||||||
|
| 2022-01-01T19:00:00Z | Kitchen | 22 | 36.6 | 23.1 |
|
||||||
|
| 2022-01-01T20:00:00Z | Kitchen | 26 | 36.5 | 22.7 |
|
||||||
|
| 2022-01-01T08:00:00Z | Living Room | 0 | 35.9 | 21.1 |
|
||||||
|
| 2022-01-01T09:00:00Z | Living Room | 0 | 35.9 | 21.4 |
|
||||||
|
| 2022-01-01T10:00:00Z | Living Room | 0 | 36 | 21.8 |
|
||||||
|
| 2022-01-01T11:00:00Z | Living Room | 0 | 36 | 22.2 |
|
||||||
|
| 2022-01-01T12:00:00Z | Living Room | 0 | 35.9 | 22.2 |
|
||||||
|
| 2022-01-01T13:00:00Z | Living Room | 0 | 36 | 22.4 |
|
||||||
|
| 2022-01-01T14:00:00Z | Living Room | 0 | 36.1 | 22.3 |
|
||||||
|
| 2022-01-01T15:00:00Z | Living Room | 1 | 36.1 | 22.3 |
|
||||||
|
| 2022-01-01T16:00:00Z | Living Room | 4 | 36 | 22.4 |
|
||||||
|
| 2022-01-01T17:00:00Z | Living Room | 5 | 35.9 | 22.6 |
|
||||||
|
| 2022-01-01T18:00:00Z | Living Room | 9 | 36.2 | 22.8 |
|
||||||
|
| 2022-01-01T19:00:00Z | Living Room | 14 | 36.3 | 22.5 |
|
||||||
|
| 2022-01-01T20:00:00Z | Living Room | 17 | 36.4 | 22.2 |
|
||||||
|
{{% /influxdb/custom-timestamps %}}
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
{{< /expand-wrapper >}}
|
||||||
|
|
||||||
|
**Congratulations!** You have written data to InfluxDB.
|
||||||
|
With data now stored in InfluxDB, let's query it.
|
||||||
|
|
||||||
|
<!-- The method described
|
||||||
|
above is the manual way of writing data, but there are other options available:
|
||||||
|
|
||||||
|
- [Write data to InfluxDB using no-code solutions](/influxdb/cloud-iox/write-data/no-code/)
|
||||||
|
- [Write data to InfluxDB using developer tools](/influxdb/cloud-iox/write-data/developer-tools/) -->
|
||||||
|
|
||||||
|
{{< page-nav prev="/influxdb/cloud-dedicated/get-started/setup/" next="/influxdb/cloud-dedicated/get-started/query/" keepTab=true >}}
|
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
title: How existing InfluxDB workloads work
|
||||||
|
description: >
|
||||||
|
Learn to use InfluxDB Cloud Dedicated for existing write and query workloads coming from InfluxDB version 1.x.
|
||||||
|
weight: 3
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Primers
|
||||||
|
influxdb/cloud-dedicated/tags: []
|
||||||
|
---
|
||||||
|
|
||||||
|
{{% children %}}
|
|
@ -0,0 +1,23 @@
|
||||||
|
---
|
||||||
|
title: Learn to use APIs for your workloads
|
||||||
|
seo_title: Learn to use APIs for your data workloads in InfluxDB Cloud Dedicated
|
||||||
|
description: >
|
||||||
|
Choose the API and tools that fit your workload.
|
||||||
|
Learn how to authenticate, write, and query using Telegraf, client libraries, and HTTP clients.
|
||||||
|
weight: 3
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: Primers
|
||||||
|
name: API primers
|
||||||
|
influxdb/cloud-dedicated/tags: [api]
|
||||||
|
# related:
|
||||||
|
# - /influxdb/cloud/api/#tag/Write, InfluxDB API /write endpoint
|
||||||
|
# - /influxdb/cloud/reference/syntax/line-protocol
|
||||||
|
# - /influxdb/cloud/reference/syntax/annotated-csv
|
||||||
|
# - /influxdb/cloud/reference/cli/influx/write
|
||||||
|
# - /resources/videos/ingest-data/, How to Ingest Data in InfluxDB (Video)
|
||||||
|
---
|
||||||
|
|
||||||
|
Choose the {{% cloud-name %}} API and tools that best fit your workload:
|
||||||
|
|
||||||
|
{{< children sort>}}
|
|
@ -0,0 +1,491 @@
|
||||||
|
---
|
||||||
|
title: Use the InfluxDB v1 API with InfluxDB Cloud Dedicated
|
||||||
|
list_title: Use the InfluxDB v1 API
|
||||||
|
description: >
|
||||||
|
Use InfluxDB v1 API authentication, endpoints, and tools.
|
||||||
|
Learn how to use InfluxDB Cloud Dedicated v1 `/query`, `/write`, and username/password authentication when bringing existing 1.x workloads.
|
||||||
|
weight: 3
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: API primers
|
||||||
|
name: v1 API primer
|
||||||
|
influxdb/cloud-dedicated/tags: [write, line protocol]
|
||||||
|
---
|
||||||
|
|
||||||
|
Use the InfluxDB v1 API with v1 workloads that you bring to InfluxDB Cloud Dedicated.
|
||||||
|
InfluxDB Cloud Dedicated v1 `/write` and `/query` endpoints work with username/password authentication and existing InfluxDB 1.x tools and code.
|
||||||
|
The InfluxDB v1 API `/write` endpoint works with
|
||||||
|
InfluxDB 1.x client libraries and the [Telegraf v1 Output Plugin](/telegraf/v1.26/plugins/#output-influxdb).
|
||||||
|
The InfluxDB v1 API `/query` endpoint supports InfluxQL and third-party integrations like [Grafana](https://grafana.com).
|
||||||
|
|
||||||
|
{{% warn %}}
|
||||||
|
{{% api/cloud/v2-prefer %}}
|
||||||
|
{{% /warn %}}
|
||||||
|
|
||||||
|
<!-- TOC -->
|
||||||
|
|
||||||
|
- [Authenticate API requests](#authenticate-api-requests)
|
||||||
|
- [Authenticate with a username and password scheme](#authenticate-with-a-username-and-password-scheme)
|
||||||
|
- [Basic authentication](#basic-authentication)
|
||||||
|
- [Syntax](#syntax)
|
||||||
|
- [Example](#example)
|
||||||
|
- [Query string authentication](#query-string-authentication)
|
||||||
|
- [Syntax](#syntax)
|
||||||
|
- [Example](#example)
|
||||||
|
- [Authenticate with a token](#authenticate-with-a-token)
|
||||||
|
- [Syntax](#syntax)
|
||||||
|
- [Examples](#examples)
|
||||||
|
- [Write data with the v1 API](#write-data-with-the-v1-api)
|
||||||
|
- [Write using Telegraf](#write-using-telegraf)
|
||||||
|
- [Other Telegraf configuration options](#other-telegraf-configuration-options)
|
||||||
|
- [Write using client libraries](#write-using-client-libraries)
|
||||||
|
- [Write using HTTP clients](#write-using-http-clients)
|
||||||
|
- [v1 API /write parameters](#v1-api-write-parameters)
|
||||||
|
- [Timestamp precision](#timestamp-precision)
|
||||||
|
- [Use clients for interactive testing](#use-clients-for-interactive-testing)
|
||||||
|
- [v1 CLI not supported](#v1-cli-not-supported)
|
||||||
|
- [Query data](#query-data)
|
||||||
|
- [Query using the v1 API](#query-using-the-v1-api)
|
||||||
|
- [v1 API /query parameters](#v1-api-query-parameters)
|
||||||
|
- [Timestamp precision](#timestamp-precision)
|
||||||
|
- [Query using HTTP clients](#query-using-http-clients)
|
||||||
|
- [Query using Flight SQL](#query-using-flight-sql)
|
||||||
|
- [Database management with InfluxQL not supported](#database-management-with-influxql-not-supported)
|
||||||
|
|
||||||
|
<!-- /TOC -->
|
||||||
|
<!--
|
||||||
|
<a class="btn" href="/influxdb/cloud-dedicated/api/v1/">View v1 API reference documentation</a>
|
||||||
|
-->
|
||||||
|
|
||||||
|
## Authenticate API requests
|
||||||
|
|
||||||
|
InfluxDB requires each write request to be authenticated with a
|
||||||
|
[database token](/influxdb/cloud-dedicated/admin/tokens/).
|
||||||
|
With the InfluxDB v1 API, you can use database tokens in InfluxDB 1.x username and password
|
||||||
|
schemes or in the InfluxDB v2 `Authorization: Token` scheme:
|
||||||
|
|
||||||
|
- [Authenticate with a username and password scheme](#authenticate-with-a-username-and-password-scheme)
|
||||||
|
- [Authenticate with a token](#authenticate-with-a-token)
|
||||||
|
|
||||||
|
### Authenticate with a username and password scheme
|
||||||
|
|
||||||
|
With the InfluxDB v1 API, you can use the InfluxDB 1.x convention of
|
||||||
|
username and password to authenticate database reads and writes by passing a
|
||||||
|
[database token](/influxdb/cloud-dedicated/admin/tokens/)
|
||||||
|
as the `password` credential.
|
||||||
|
When authenticating requests to the v1 API `/write` and `/query` endpoints, InfluxDB Cloud Dedicated checks that `password` (`p`) is an authorized [database token](/influxdb/cloud-dedicated/admin/tokens/).
|
||||||
|
InfluxDB Cloud ignores the `username` (`u`) parameter in the request.
|
||||||
|
|
||||||
|
Use one of the following authentication schemes with clients that support Basic authentication or query parameters (that don't support [token authentication](#authenticate-with-a-token)):
|
||||||
|
|
||||||
|
- [Basic authentication](#basic-authentication)
|
||||||
|
- [Query string authentication](#query-string-authentication)
|
||||||
|
|
||||||
|
#### Basic authentication
|
||||||
|
|
||||||
|
Use the `Authorization` header with the `Basic` scheme to authenticate v1 API `/write` and `/query` requests.
|
||||||
|
When authenticating requests, InfluxDB Cloud Dedicated checks that the `password` part of the decoded credential is an authorized [database token](/influxdb/cloud-dedicated/admin/tokens/).
|
||||||
|
InfluxDB Cloud Dedicated ignores the `username` part of the decoded credential.
|
||||||
|
|
||||||
|
##### Syntax
|
||||||
|
|
||||||
|
```http
|
||||||
|
Authorization: Basic <base64-encoded [USERNAME]:DATABASE_TOKEN>
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace the following:
|
||||||
|
|
||||||
|
- **`[USERNAME]`**: an optional string value (ignored by InfluxDB Cloud Dedicated).
|
||||||
|
- **`DATABASE_TOKEN`**: a [database token](/influxdb/cloud-dedicated/admin/tokens/).
|
||||||
|
- Encode the `[USERNAME]:DATABASE_TOKEN` credential using base64 encoding, and then append the encoded string to the `Authorization: Basic` header.
|
||||||
|
|
||||||
|
{{% api/v1-compat/basic-auth-syntax %}}
|
||||||
|
|
||||||
|
##### Example
|
||||||
|
|
||||||
|
The following example shows how to use cURL with the `Basic` authentication scheme and a [database token](/influxdb/cloud-dedicated/admin/tokens/):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
{{% get-shared-text "api/cloud-dedicated/basic-auth.sh" %}}
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace the following:
|
||||||
|
|
||||||
|
- **`DATABASE_NAME`**: your InfluxDB Cloud Dedicated database
|
||||||
|
- **`DATABASE_TOKEN`**: a [database token](/influxdb/cloud-dedicated/admin/tokens/) with sufficient permissions to the database
|
||||||
|
|
||||||
|
#### Query string authentication
|
||||||
|
|
||||||
|
In the URL, pass the `p` query parameter to authenticate `/write` and `/query` requests.
|
||||||
|
When authenticating requests, InfluxDB Cloud Dedicated checks that `p` (_password_) is an authorized database token and ignores the `u` (_username_) parameter.
|
||||||
|
|
||||||
|
##### Syntax
|
||||||
|
|
||||||
|
```sh
|
||||||
|
https://cluster-id.influxdb.io/query/?[u=any]&p=DATABASE_TOKEN
|
||||||
|
https://cluster-id.influxdb.io/write/?[u=any]&p=DATABASE_TOKEN
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Example
|
||||||
|
|
||||||
|
The following example shows how to use cURL with query string authentication and [database token](/influxdb/cloud-dedicated/admin/tokens/).
|
||||||
|
|
||||||
|
```sh
|
||||||
|
{{% get-shared-text "api/cloud-dedicated/querystring-auth.sh" %}}
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace the following:
|
||||||
|
|
||||||
|
- **`DATABASE_NAME`**: your InfluxDB Cloud Dedicated database
|
||||||
|
- **`DATABASE_TOKEN`**: a [database token](/influxdb/cloud-dedicated/admin/tokens/) with sufficient permissions to the database
|
||||||
|
|
||||||
|
### Authenticate with a token
|
||||||
|
|
||||||
|
Use the `Authorization: Bearer` or the `Authorization: Token` scheme to pass a [database token](/influxdb/cloud-dedicated/admin/tokens/) for authenticating
|
||||||
|
v1 API `/write` and `/query` requests.
|
||||||
|
In the InfluxDB Cloud Dedicated HTTP API, the schemes are equivalent.
|
||||||
|
The `Token` scheme is used in the InfluxDB 2.x API.
|
||||||
|
The [`Bearer` scheme](https://www.rfc-editor.org/rfc/rfc6750#page-14) is more common.
|
||||||
|
Support for one or the other may vary across InfluxDB API clients.
|
||||||
|
|
||||||
|
#### Syntax
|
||||||
|
|
||||||
|
```http
|
||||||
|
Authorization: Bearer DATABASE_TOKEN
|
||||||
|
```
|
||||||
|
|
||||||
|
```http
|
||||||
|
Authorization: Token DATABASE_TOKEN
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Examples
|
||||||
|
|
||||||
|
Use `Bearer` to authenticate a write request:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
{{% get-shared-text "api/cloud-dedicated/bearer-auth-v1-write.sh" %}}
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `Token` to authenticate a write request:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
{{% get-shared-text "api/cloud-dedicated/token-auth-v1-write.sh" %}}
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace the following:
|
||||||
|
|
||||||
|
- **`DATABASE_NAME`**: your InfluxDB Cloud Dedicated database
|
||||||
|
- **`DATABASE_TOKEN`**: a [database token](/influxdb/cloud-dedicated/admin/tokens/) with sufficient permissions to the database
|
||||||
|
|
||||||
|
<!-- ## Responses -->
|
||||||
|
|
||||||
|
## Write data with the v1 API
|
||||||
|
|
||||||
|
Write data with your existing workloads that already use the InfluxDB v1 API or v1.x-compatibility API.
|
||||||
|
|
||||||
|
See how to set parameters and configure the following tools for writing to InfluxDB Cloud Dedicated:
|
||||||
|
|
||||||
|
- [Write using Telegraf](#write-using-telegraf)
|
||||||
|
- [Write using client libraries](#write-using-client-libraries)
|
||||||
|
- [Write using HTTP clients](#write-using-http-clients)
|
||||||
|
- [v1 API /write parameters](#v1-api-write-parameters)
|
||||||
|
- [Use clients for interactive testing](#use-clients-for-interactive-testing)
|
||||||
|
|
||||||
|
### Write using Telegraf
|
||||||
|
|
||||||
|
If you have existing v1 workloads that use Telegraf,
|
||||||
|
you can use the [InfluxDB v1.x `influxdb` Telegraf output plugin](https://github.com/influxdata/telegraf/blob/master/plugins/outputs/influxdb/README.md) to write data.
|
||||||
|
|
||||||
|
{{% warn %}}
|
||||||
|
Use [Telegraf and the v2 API](/influxdb/cloud-dedicated/primers/api/v2/) for new workloads that don't use already use the v1 API.
|
||||||
|
{{% /warn %}}
|
||||||
|
|
||||||
|
The following table shows `outputs.influxdb` parameters and values writing
|
||||||
|
to InfluxDB Cloud Dedicated:
|
||||||
|
|
||||||
|
Parameter | Ignored | Value
|
||||||
|
-------------------------|--------------------------|---------------------------------------------------------------------------------------------------
|
||||||
|
`database` | Honored | Database name
|
||||||
|
`retention_policy` | Honored, but discouraged | [Duration](/influxdb/cloud-dedicated/reference/glossary/#duration)
|
||||||
|
`username` | Ignored | String or empty
|
||||||
|
`password` | Honored | [Database token](/influxdb/cloud-dedicated/admin/tokens/) with permission to write to the database
|
||||||
|
`content_encoding` | Honored | `gzip` (compressed data) or `identity` (uncompressed)
|
||||||
|
`skip_database_creation` | Ignored | N/A (see how to [create a database](/influxdb/cloud-dedicated/admin/databases/create/))
|
||||||
|
|
||||||
|
To configure the v1.x output plugin for writing to InfluxDB Cloud Dedicated,
|
||||||
|
add the following `outputs.influxdb` configuration in your `telegraf.conf` file:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[[outputs.influxdb]]
|
||||||
|
urls = ["https://cluster-id.influxdb.io"]
|
||||||
|
database = "DATABASE_NAME"
|
||||||
|
skip_database_creation = true
|
||||||
|
retention_policy = ""
|
||||||
|
username = "ignored"
|
||||||
|
password = "DATABASE_TOKEN"
|
||||||
|
content_encoding = "gzip”
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace the following:
|
||||||
|
|
||||||
|
- **`DATABASE_NAME`**: your InfluxDB Cloud Dedicated database
|
||||||
|
- **`DATABASE_TOKEN`**: a [database token](/influxdb/cloud-dedicated/get-started/setup/#create-a-database-token) with permission to write to the database
|
||||||
|
|
||||||
|
#### Other Telegraf configuration options
|
||||||
|
|
||||||
|
`influx_uint_support`: supported in InfluxDB IOx.
|
||||||
|
|
||||||
|
For more plugin options, see [`influxdb`](https://github.com/influxdata/telegraf/blob/master/plugins/outputs/influxdb/README.md) on GitHub.
|
||||||
|
|
||||||
|
### Write using client libraries
|
||||||
|
|
||||||
|
Use language-specific [v1 client libraries](/influxdb/v1.8/tools/api_client_libraries/) and your custom code to write data to InfluxDB Cloud Dedicated.
|
||||||
|
v1 client libraries send data in [line protocol](/influxdb/cloud-dedicated/reference/syntax/line-protocol/) syntax to the v1 API `/write` endpoint.
|
||||||
|
|
||||||
|
The following samples show how to configure **v1** client libraries for writing to InfluxDB Cloud Dedicated:
|
||||||
|
|
||||||
|
{{< code-tabs-wrapper >}}
|
||||||
|
{{% code-tabs %}}
|
||||||
|
[Node.js](#nodejs)
|
||||||
|
[Python](#python)
|
||||||
|
{{% /code-tabs %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
<!-- Start NodeJS -->
|
||||||
|
|
||||||
|
Create a v1 API client using the [node-influx](/influxdb/v1.7/tools/api_client_libraries/#javascriptnodejs) JavaScript client library:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const Influx = require('influx')
|
||||||
|
|
||||||
|
// Instantiate a client for writing to InfluxDB Cloud Dedicated v1 API
|
||||||
|
const client = new Influx.InfluxDB({
|
||||||
|
host: 'cluster-id.influxdb.io',
|
||||||
|
port: 443,
|
||||||
|
protocol: 'https'
|
||||||
|
database: 'DATABASE_NAME',
|
||||||
|
username: 'ignored',
|
||||||
|
password: 'DATABASE_TOKEN'
|
||||||
|
})
|
||||||
|
```
|
||||||
|
<!-- End NodeJS -->
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
<!-- Start Python -->
|
||||||
|
|
||||||
|
Create a v1 API client using the [influxdb-python](/influxdb/v1.7/tools/api_client_libraries/#python) Python client library:
|
||||||
|
|
||||||
|
```py
|
||||||
|
from influxdb import InfluxDBClient
|
||||||
|
|
||||||
|
# Instantiate a client for writing to InfluxDB Cloud Dedicated v1 API
|
||||||
|
client = InfluxDBClient(
|
||||||
|
host='cluster-id.influxdb.io',
|
||||||
|
ssl=True,
|
||||||
|
database='DATABASE_NAME',
|
||||||
|
username='',
|
||||||
|
password='DATABASE_TOKEN'
|
||||||
|
headers={'Content-Type': 'text/plain; charset=utf-8'}
|
||||||
|
)
|
||||||
|
```
|
||||||
|
<!-- End Python -->
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{< /code-tabs-wrapper >}}
|
||||||
|
|
||||||
|
Replace the following:
|
||||||
|
|
||||||
|
- **`DATABASE_NAME`**: your InfluxDB Cloud Dedicated database
|
||||||
|
- **`DATABASE_TOKEN`**: a [database token](/influxdb/cloud-dedicated/admin/tokens/) with sufficient permissions to the database
|
||||||
|
|
||||||
|
### Write using HTTP clients
|
||||||
|
|
||||||
|
Use HTTP clients and your custom code to send write requests to the v1 API `/write` endpoint.
|
||||||
|
|
||||||
|
{{% api-endpoint endpoint="https://cluster-id.influxdb.io/write" method="post"%}}
|
||||||
|
|
||||||
|
Include the following in your request:
|
||||||
|
|
||||||
|
- A `db` query string parameter with the name of the database to write to.
|
||||||
|
- A request body that contains a string of data in [line protocol](/influxdb/cloud-dedicated/reference/syntax/line-protocol/) syntax.
|
||||||
|
- A [database token](/influxdb/cloud-dedicated/admin/tokens/) in one of the following authentication schemes: [Basic authentication](#basic-authentication), [query string authentication](#query-string-authentication), or [token authentication](#authenticate-with-a-token).
|
||||||
|
- Optional [parameters](#v1-api-write-parameters).
|
||||||
|
|
||||||
|
#### v1 API /write parameters
|
||||||
|
|
||||||
|
Parameter | Allowed in | Ignored | Value
|
||||||
|
-----------------------|--------------|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
`consistency` | Query string | Ignored | N/A
|
||||||
|
`db` {{% req " \*" %}} | Query string | Honored | Database name
|
||||||
|
`precision` | Query string | Honored | [Timestamp precision](#timestamp-precision)
|
||||||
|
`rp` | Query string | Honored, but discouraged | Retention policy
|
||||||
|
`u` | Query string | Ignored | For [query string authentication](#query-string-authentication), any arbitrary string
|
||||||
|
`p` | Query string | Honored | For [query string authentication](#query-string-authentication), a [database token](/influxdb/cloud-dedicated/get-started/setup/#create-a-database-token) with permission to write to the database
|
||||||
|
`Content-Encoding` | Header | Honored | `gzip` (compressed data) or `identity` (uncompressed)
|
||||||
|
`Authorization` | Header | Honored | `Bearer DATABASE_TOKEN`, `Token DATABASE_TOKEN`, or `Basic <base64 [USERNAME]:DATABASE_TOKEN>`
|
||||||
|
|
||||||
|
{{% caption %}}{{% req " \*" %}} = {{% req "Required" %}}{{% /caption %}}
|
||||||
|
|
||||||
|
#### Timestamp precision
|
||||||
|
|
||||||
|
Use one of the following `precision` values in v1 API `/write` requests:
|
||||||
|
|
||||||
|
- `ns`: nanoseconds
|
||||||
|
- `u`: microseconds <!-- @TODO: test that differs from `us` used in v2?? -->
|
||||||
|
- `ms`: milliseconds
|
||||||
|
- `s`: seconds
|
||||||
|
- `m`: minutes
|
||||||
|
- `h`: hours
|
||||||
|
|
||||||
|
#### Use clients for interactive testing
|
||||||
|
|
||||||
|
To test interactively, use common HTTP clients such as cURL and Postman to send requests to the v1 API `/write` endpoint.
|
||||||
|
|
||||||
|
{{% warn %}}
|
||||||
|
While the v1 CLI may coincidentally work with InfluxDB Cloud Dedicated, it isn't officially supported.
|
||||||
|
{{% /warn %}}
|
||||||
|
|
||||||
|
The following example shows how to use the **cURL** command line tool and the InfluxDB Cloud Dedicated v1 API to write line protocol data to a database:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
curl -i 'https://cluster-id.influxdb.io/write?db=DATABASE_NAME&precision=s' \
|
||||||
|
--header 'Authorization: Token DATABASE_TOKEN' \
|
||||||
|
--header "Content-type: text/plain; charset=utf-8"
|
||||||
|
--data-binary 'home,room=kitchen temp=72 1463683075'
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace the following:
|
||||||
|
|
||||||
|
- **`DATABASE_NAME`**: your InfluxDB Cloud Dedicated database
|
||||||
|
- **`DATABASE_TOKEN`**: a [database token](/influxdb/cloud-dedicated/admin/tokens/) with sufficient permissions to the database
|
||||||
|
|
||||||
|
### v1 CLI (not supported)
|
||||||
|
|
||||||
|
Don't use the v1 CLI with {{% cloud-name %}}.
|
||||||
|
While it may coincidentally work, it isn't officially supported.
|
||||||
|
|
||||||
|
If you need to test writes interactively, see how to [write using HTTP clients](#write-using-http-clients).
|
||||||
|
|
||||||
|
## Query data
|
||||||
|
|
||||||
|
### Query using the v1 API
|
||||||
|
|
||||||
|
Use the v1 API `/query` endpoint and [InfluxQL](/influxdb/cloud-dedicated/reference/glossary/#influxql) with InfluxDB Cloud Dedicated when you
|
||||||
|
bring InfluxDB 1.x workloads that already use them.
|
||||||
|
|
||||||
|
InfluxDB Cloud Dedicated
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
For new workloads, see how to [query using Flight SQL](#query-using-flight-sql).
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
|
#### v1 API /query parameters
|
||||||
|
|
||||||
|
Parameter | Allowed in | Ignored | Value
|
||||||
|
----------|------------|---------|-------------------------------------------------------------------------
|
||||||
|
`chunked` | | Ignored | N/A _(Note that an unbounded query might return a large amount of data)_
|
||||||
|
`db` | Query string | Honored | Database name |
|
||||||
|
`epoch` | Query string | Honored | [Timestamp precision](#timestamp-precision) |
|
||||||
|
`p` | Query string | Honored | Database token
|
||||||
|
`pretty` | Query string | Ignored | N/A
|
||||||
|
`u` | Query string | Ignored | For [query string authentication](#query-string-authentication), any arbitrary string
|
||||||
|
`p` | Query string | Honored | For [query string authentication](#query-string-authentication), a [database token](/influxdb/cloud-dedicated/get-started/setup/#create-a-database-token) with permission to write to the database
|
||||||
|
`rp` | Query string | Honored, but discouraged | Retention policy
|
||||||
|
|
||||||
|
#### Timestamp precision
|
||||||
|
|
||||||
|
Use one of the following values for timestamp precision:
|
||||||
|
|
||||||
|
- `ns`: nanoseconds
|
||||||
|
- `u`: microseconds <!-- @TODO: test that differs from `us` used in v2?? -->
|
||||||
|
- `ms`: milliseconds
|
||||||
|
- `s`: seconds
|
||||||
|
- `m`: minutes
|
||||||
|
- `h`: hours
|
||||||
|
|
||||||
|
#### Query using HTTP clients
|
||||||
|
|
||||||
|
Use HTTP clients and your custom code to send InfluxQL queries to the v1 API `/query` endpoint.
|
||||||
|
|
||||||
|
{{% api-endpoint endpoint="https://cluster-id.influxdb.io/query" method="get"%}}
|
||||||
|
|
||||||
|
Include the following in your request:
|
||||||
|
|
||||||
|
- A `db` query string parameter with the name of the database to write to.
|
||||||
|
- A [database token](/influxdb/cloud-dedicated/admin/tokens/) in one of the following authentication schemes: [Basic authentication](#basic-authentication), [query string authentication](#query-string-authentication), or [token authentication](#authenticate-with-a-token).
|
||||||
|
- A `q` query string parameter with the InfluxQL query.
|
||||||
|
- Optional [parameters](#v1-api-query-parameters).
|
||||||
|
|
||||||
|
The following examples show how to query using the v1 API `/query` endpoint and InfluxQL:
|
||||||
|
|
||||||
|
{{< code-tabs-wrapper >}}
|
||||||
|
{{% code-tabs %}}
|
||||||
|
[cURL](#curl)
|
||||||
|
[Python](#python)
|
||||||
|
{{% /code-tabs %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
<!-- Begin cURL -->
|
||||||
|
```sh
|
||||||
|
{{% get-shared-text "api/cloud-dedicated/bearer-auth-v1-query.sh" %}}
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
{{% get-shared-text "api/cloud-dedicated/token-auth-v1-query.sh" %}}
|
||||||
|
```
|
||||||
|
<!-- End cURL -->
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
<!-- Begin python influxdb v1 client library -->
|
||||||
|
```py
|
||||||
|
from influxdb import InfluxDBClient
|
||||||
|
import os
|
||||||
|
|
||||||
|
DATABASE_NAME = os.getenv('CLOUD_DEDICATED_DATABASE_NAME')
|
||||||
|
DATABASE_TOKEN = os.getenv('CLOUD_DEDICATED_DATABASE_TOKEN')
|
||||||
|
INFLUXDB_URL=os.getenv('CLOUD_DEDICATED_URL')
|
||||||
|
INFLUXDB_HOST=os.getenv('CLOUD_DEDICATED_HOST')
|
||||||
|
|
||||||
|
def influxdb_v1_client(headers=None):
|
||||||
|
client = InfluxDBClient(
|
||||||
|
host=INFLUXDB_HOST,
|
||||||
|
port=443,
|
||||||
|
ssl=True,
|
||||||
|
database=DATABASE_NAME,
|
||||||
|
username='USERNAME',
|
||||||
|
password=DATABASE_TOKEN,
|
||||||
|
headers=headers
|
||||||
|
)
|
||||||
|
print(vars(client))
|
||||||
|
return client
|
||||||
|
|
||||||
|
def query_influxql():
|
||||||
|
client = influxdb_v1_client()
|
||||||
|
response = client.query('SHOW MEASUREMENTS')
|
||||||
|
print(response)
|
||||||
|
return response
|
||||||
|
```
|
||||||
|
<!-- End python -->
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{< /code-tabs-wrapper >}}
|
||||||
|
|
||||||
|
The response body contains query results in JSON format.
|
||||||
|
|
||||||
|
### Query using Flight SQL
|
||||||
|
|
||||||
|
Use Flight SQL clients with gRPC and SQL to query data stored in an InfluxDB Cloud Dedicated database.
|
||||||
|
|
||||||
|
### Database management with InfluxQL (not supported)
|
||||||
|
|
||||||
|
InfluxDB Cloud Dedicated doesn't allow InfluxQL commands for managing or modifying databases.
|
||||||
|
You can't use the following InfluxQL commands:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT INTO
|
||||||
|
CREATE
|
||||||
|
DELETE
|
||||||
|
DROP
|
||||||
|
GRANT
|
||||||
|
EXPLAIN
|
||||||
|
REVOKE
|
||||||
|
ALTER
|
||||||
|
SET
|
||||||
|
KILL
|
||||||
|
```
|
|
@ -0,0 +1,338 @@
|
||||||
|
---
|
||||||
|
title: Use the InfluxDB v2 API with InfluxDB Cloud Dedicated
|
||||||
|
list_title: Use the InfluxDB v2 API
|
||||||
|
description: >
|
||||||
|
Use InfluxDB v2 API authentication, endpoints, and tools.
|
||||||
|
Learn how to use InfluxDB Cloud Dedicated v2 `/api/v2/write` and authentication
|
||||||
|
for new and existing workloads.
|
||||||
|
weight: 1
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: API primers
|
||||||
|
name: v2 API primer
|
||||||
|
influxdb/cloud-dedicated/tags: [write, line protocol]
|
||||||
|
---
|
||||||
|
|
||||||
|
Use the InfluxDB v2 API for new workloads and existing v2 workloads that you bring to InfluxDB Cloud Dedicated.
|
||||||
|
The InfluxDB Cloud Dedicated v2 `/api/v2/write` endpoint works with token authentication
|
||||||
|
and existing InfluxDB 2.x tools and code.
|
||||||
|
For help finding the best workflow for your situation, [contact Support](mailto:support@influxdata.com).
|
||||||
|
|
||||||
|
<!-- v2 SAMPLE CODE -->
|
||||||
|
|
||||||
|
<!-- TOC -->
|
||||||
|
|
||||||
|
- [Authenticate API requests](#authenticate-api-requests)
|
||||||
|
- [Authenticate with a token](#authenticate-with-a-token)
|
||||||
|
- [Syntax](#syntax)
|
||||||
|
- [Examples](#examples)
|
||||||
|
- [Responses](#responses)
|
||||||
|
- [Errors](#errors)
|
||||||
|
- [Write data](#write-data)
|
||||||
|
- [Write using Telegraf](#write-using-telegraf)
|
||||||
|
- [Other Telegraf configuration options](#other-telegraf-configuration-options)
|
||||||
|
- [Write using client libraries](#write-using-client-libraries)
|
||||||
|
- [Write using HTTP clients](#write-using-http-clients)
|
||||||
|
- [v2 API /api/v2/write parameters](#v2-api-apiv2write-parameters)
|
||||||
|
- [Timestamp precision](#timestamp-precision)
|
||||||
|
- [Use clients for interactive testing](#use-clients-for-interactive-testing)
|
||||||
|
- [influx CLI not supported](#influx-cli-not-supported)
|
||||||
|
- [Query data](#query-data)
|
||||||
|
- [Query using Flight SQL](#query-using-flight-sql)
|
||||||
|
- [/api/v2/query not supported](#apiv2query-not-supported)
|
||||||
|
|
||||||
|
<!-- /TOC -->
|
||||||
|
|
||||||
|
## Authenticate API requests
|
||||||
|
|
||||||
|
InfluxDB requires each write request to be authenticated with a
|
||||||
|
[database token](/influxdb/cloud-dedicated/admin/tokens/).
|
||||||
|
|
||||||
|
### Authenticate with a token
|
||||||
|
|
||||||
|
Use the `Authorization: Bearer` or the `Authorization: Token` scheme to pass a [database token](/influxdb/cloud-dedicated/admin/tokens/) that has _write_ permission to your database.
|
||||||
|
In the InfluxDB Cloud Dedicated HTTP API, the schemes are equivalent.
|
||||||
|
The `Token` scheme is used in the InfluxDB 2.x API.
|
||||||
|
The [`Bearer` scheme](https://www.rfc-editor.org/rfc/rfc6750#page-14) is more common.
|
||||||
|
Support for one or the other may vary across InfluxDB API clients.
|
||||||
|
|
||||||
|
#### Syntax
|
||||||
|
|
||||||
|
```http
|
||||||
|
Authorization: Bearer DATABASE_TOKEN
|
||||||
|
```
|
||||||
|
|
||||||
|
```http
|
||||||
|
Authorization: Token DATABASE_TOKEN
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Examples
|
||||||
|
|
||||||
|
Use `Bearer` to authenticate a write request:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
{{% get-shared-text "api/cloud-dedicated/bearer-auth-v2-write.sh" %}}
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `Token` to authenticate a write request:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
{{% get-shared-text "api/cloud-dedicated/token-auth-v2-write.sh" %}}
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace the following:
|
||||||
|
|
||||||
|
- **`DATABASE_NAME`**: your InfluxDB Cloud Dedicated database
|
||||||
|
- **`DATABASE_TOKEN`**: a [database token](/influxdb/cloud-dedicated/admin/tokens/) with sufficient permissions to the database
|
||||||
|
|
||||||
|
## Responses
|
||||||
|
|
||||||
|
InfluxDB Cloud Dedicated API responses use standard HTTP status codes.
|
||||||
|
InfluxDB Cloud Dedicated API response body messages may differ from InfluxDB Cloud and InfluxDB OSS.
|
||||||
|
|
||||||
|
### Errors
|
||||||
|
|
||||||
|
```sh
|
||||||
|
Status code: 400
|
||||||
|
Reason: Bad Request
|
||||||
|
HTTP response body: {"code":"invalid","message":"missing bucket value"}
|
||||||
|
```
|
||||||
|
|
||||||
|
The request is missing the `bucket` parameter value.
|
||||||
|
For `bucket`, provide the database name.
|
||||||
|
|
||||||
|
## Write data
|
||||||
|
|
||||||
|
Use the InfluxDB Cloud Dedicated v2 API `/api/v2/write` endpoint to write data to a database.
|
||||||
|
We recommend using the v2 API `/api/v2/write` endpoint
|
||||||
|
for new and existing workloads.
|
||||||
|
|
||||||
|
See how to set parameters and configure the following tools for writing to InfluxDB Cloud Dedicated:
|
||||||
|
|
||||||
|
- [Write using Telegraf](#write-using-telegraf)
|
||||||
|
- [Write using client libraries](#write-using-client-libraries)
|
||||||
|
- [Write using HTTP clients](#write-using-http-clients)
|
||||||
|
- [v2 API /api/v2/write parameters](#v2-api-apiv2write-parameters)
|
||||||
|
- [Use clients for interactive testing](#use-clients-for-interactive-testing)
|
||||||
|
|
||||||
|
### Write using Telegraf
|
||||||
|
|
||||||
|
Use the [InfluxDB v2.x `influxdb_v2` Telegraf output plugin](https://github.com/influxdata/telegraf/blob/master/plugins/outputs/influxdb_v2/README.md) to write data.
|
||||||
|
|
||||||
|
The following table shows `outputs.influxdb` parameters and values for writing
|
||||||
|
to InfluxDB Cloud Dedicated:
|
||||||
|
|
||||||
|
Parameter | Ignored | Value
|
||||||
|
-------------------------|--------------------------|--------------------------------------------------------------------------------------------------------------------------------|
|
||||||
|
`token` | Honored | [Database token](/influxdb/cloud-dedicated/admin/tokens/) with permission to write to the database |
|
||||||
|
`organization` | Ignored | |
|
||||||
|
`bucket` | Honored | Database name |
|
||||||
|
`content_encoding` | Honored | `gzip` (compressed data) or `identity` (uncompressed) |
|
||||||
|
|
||||||
|
To configure the v2.x output plugin for writing to InfluxDB Cloud Dedicated,
|
||||||
|
add the following `outputs.influxdb_v2` configuration in your `telegraf.conf` file:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[[outputs.influxdb_v2]]
|
||||||
|
urls = ["https://cluster-id.influxdb.io"]
|
||||||
|
token = "DATABASE_TOKEN"
|
||||||
|
organization = ""
|
||||||
|
bucket = "DATABASE_NAME"
|
||||||
|
content_encoding = "gzip"
|
||||||
|
influx_uint_support = false
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace the following:
|
||||||
|
|
||||||
|
- **`DATABASE_NAME`**: your InfluxDB Cloud Dedicated database
|
||||||
|
- **`DATABASE_TOKEN`**: a [database token](/influxdb/cloud-dedicated/admin/tokens/) with permission to write to the database
|
||||||
|
|
||||||
|
#### Other Telegraf configuration options
|
||||||
|
|
||||||
|
`influx_uint_support`: supported in InfluxDB IOx.
|
||||||
|
|
||||||
|
For more plugin options, see [`influxdb_v2`](https://github.com/influxdata/telegraf/blob/master/plugins/outputs/influxdb_v2/README.md) on GitHub.
|
||||||
|
|
||||||
|
### Write using client libraries
|
||||||
|
|
||||||
|
Use language-specific [v2 client libraries](/influxdb/cloud/api-guide/client-libraries/) and your custom code to write data to InfluxDB Cloud Dedicated.
|
||||||
|
v2 client libraries send data in [line protocol](/influxdb/cloud-dedicated/reference/syntax/line-protocol/) syntax to the v2 API `/api/v2/write` endpoint.
|
||||||
|
|
||||||
|
The following samples show how to configure **v2** client libraries for writing to InfluxDB Cloud Dedicated:
|
||||||
|
|
||||||
|
{{< code-tabs-wrapper >}}
|
||||||
|
{{% code-tabs %}}
|
||||||
|
[Node.js](#nodejs)
|
||||||
|
[Python](#python)
|
||||||
|
{{% /code-tabs %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
<!-- Start NodeJS -->
|
||||||
|
|
||||||
|
Create a v2 API client using the [`influxdb-client-js`](https://github.com/influxdata/influxdb-client-js) JavaScript client library:
|
||||||
|
|
||||||
|
1. Call the `InfluxDB({url, token})` constructor to instantiate an `InfluxDB` client. Provide the InfluxDB **URL** and a [database token](/influxdb/cloud-dedicated/admin/tokens/).
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {InfluxDB, Point} from '@influxdata/influxdb-client'
|
||||||
|
|
||||||
|
const influxDB = new InfluxDB({'https://cluster-id.influxdb.io', DATABASE_TOKEN})
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Call the client's [`getWriteApi(org, bucket, precision, writeOptions)` method](https://influxdata.github.io/influxdb-client-js/influxdb-client.influxdb.getwriteapi.html) to instantiate a **write client** for writing data to the `/api/v2/write` endpoint.
|
||||||
|
|
||||||
|
Provide the following parameter values:
|
||||||
|
|
||||||
|
- `org`: an arbitrary string (the parameter is ignored by InfluxDB Cloud Dedicated, but required by the client)
|
||||||
|
- `bucket`: InfluxDB Cloud Dedicated database
|
||||||
|
- `precision`: a [timestamp precision](#timestamp-precision) (`ns`, `u`, `ms`, `s`, `m`, `h`)
|
||||||
|
|
||||||
|
```js
|
||||||
|
const writeApi = influxDB.getWriteApi('', DATABASE_NAME, 'ns')
|
||||||
|
```
|
||||||
|
|
||||||
|
For more information about **write client** features in the InfluxDB 2.x JavaScript client library, see [`influxdb-client-js`](https://github.com/influxdata/influxdb-client-js) and the [`WriteAPI` interface](https://influxdata.github.io/influxdb-client-js/influxdb-client.writeapi.html) on GitHub.
|
||||||
|
|
||||||
|
<!-- End NodeJS -->
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
<!-- Start Python -->
|
||||||
|
|
||||||
|
Create a v2 API client using the [influxdb-client-python](https://github.com/influxdata/influxdb-client-python) Python client library:
|
||||||
|
|
||||||
|
1. Call the `InfluxDBClient(url, token, org)` constructor to instantiate an `InfluxDBClient`.
|
||||||
|
|
||||||
|
Provide the following parameter values:
|
||||||
|
|
||||||
|
- `url=`: InfluxDB Cloud Dedicated cluster URL
|
||||||
|
- `token=`: a [database token](/influxdb/cloud-dedicated/admin/tokens/)
|
||||||
|
- `org`: an arbitrary string (the parameter is ignored by InfluxDB Cloud Dedicated, but required by the client)
|
||||||
|
|
||||||
|
```py
|
||||||
|
influxdb_client = InfluxDBClient(url='https://cluster-id.influxdb.io',
|
||||||
|
token='DATABASE_TOKEN',
|
||||||
|
org='ignored')
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Call the `InfluxDBClient.write_api(write_options)` method to instantiate a **write client**.
|
||||||
|
|
||||||
|
```py
|
||||||
|
write_api = influxdb_client.write_api(write_options=SYNCHRONOUS)
|
||||||
|
```
|
||||||
|
|
||||||
|
3. To write data, call the `write_api.write()` method.
|
||||||
|
|
||||||
|
Provide the following parameter values:
|
||||||
|
|
||||||
|
- `bucket=`: InfluxDB Cloud Dedicated database
|
||||||
|
- `record=`: the point data to write
|
||||||
|
|
||||||
|
The following sample constructs a `Data Point`, calls `write()` to add the point to a line protocol batch,
|
||||||
|
and then calls `write_api.close()` to write the batch:
|
||||||
|
|
||||||
|
```py
|
||||||
|
write_api.write(bucket='DATABASE_NAME', record="home,room=kitchen temp=72 1463683075")
|
||||||
|
write_api.close()
|
||||||
|
```
|
||||||
|
|
||||||
|
For more information about the Python client library for the InfluxDB v2 API, see [`influxdb-client-python`](https://github.com/influxdata/influxdb-client-python) on GitHub.
|
||||||
|
<!-- End Python -->
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{< /code-tabs-wrapper >}}
|
||||||
|
|
||||||
|
Replace the following:
|
||||||
|
|
||||||
|
- **`DATABASE_NAME`**: your InfluxDB Cloud Dedicated database
|
||||||
|
- **`DATABASE_TOKEN`**: a [database token](/influxdb/cloud-dedicated/admin/tokens/) with sufficient permissions to the database
|
||||||
|
|
||||||
|
### Write using HTTP clients
|
||||||
|
|
||||||
|
Use HTTP clients and your custom code to send write requests to the v2 API `/api/v2/write` endpoint.
|
||||||
|
|
||||||
|
{{% api-endpoint endpoint="https://cluster-id.influxdb.io/api/v2/write" method="post"%}}
|
||||||
|
|
||||||
|
Include the following in your request:
|
||||||
|
|
||||||
|
- A `bucket` query string parameter with the name of the database to write to.
|
||||||
|
- A request body that contains a string of data in [line protocol](/influxdb/cloud-dedicated/reference/syntax/line-protocol/) syntax.
|
||||||
|
- A [database token](/influxdb/cloud-dedicated/admin/tokens/) in a [token authentication scheme](#authenticate-with-a-token).
|
||||||
|
- Optional [parameters](#v2-api-apiv2write-parameters).
|
||||||
|
|
||||||
|
#### v2 API /api/v2/write parameters
|
||||||
|
|
||||||
|
Parameter | Allowed in | Ignored | Value
|
||||||
|
-----------------|--------------|---------|-------------------------
|
||||||
|
org | Query string | Ignored | Non-zero-length string (ignored, but can't be empty)
|
||||||
|
orgID | Query string | Ignored | N/A
|
||||||
|
bucket {{% req " \*" %}} | Query string | Honored | Database name
|
||||||
|
precision | Query string | Honored | [Timestamp precision](#timestamp-precision): `ns`, `u`, `ms`, `s`, `m`, `h` <!-- default? ns? -->
|
||||||
|
Accept | Header | Honored | User-defined
|
||||||
|
`Authorization` {{% req " \*" %}} | Header | Honored | `Token DATABASE_TOKEN`
|
||||||
|
`Content-Encoding` | Header | Honored | `gzip` (compressed data) or `identity` (uncompressed)
|
||||||
|
Content-Length | Header | Honored | User-defined
|
||||||
|
Content-Type | Header | Ignored | N/A (only supports line protocol)
|
||||||
|
Zap-Trace-Span | Header | Ignored |
|
||||||
|
|
||||||
|
{{% caption %}}{{% req " \*" %}} = {{% req "Required" %}}{{% /caption %}}
|
||||||
|
|
||||||
|
#### Timestamp precision
|
||||||
|
|
||||||
|
Use one of the following `precision` values in v2 API `/api/v2/write` requests:
|
||||||
|
|
||||||
|
- `ns`: nanoseconds
|
||||||
|
- `us`: microseconds <!-- @TODO: test that differs from `us` used in v2?? -->
|
||||||
|
- `ms`: milliseconds
|
||||||
|
- `s`: seconds
|
||||||
|
- `m`: minutes
|
||||||
|
- `h`: hours
|
||||||
|
|
||||||
|
#### Use clients for interactive testing
|
||||||
|
|
||||||
|
To test interactively, use common HTTP clients such as cURL and Postman to send requests to the v2 API `/api/v2/write` endpoint.
|
||||||
|
|
||||||
|
{{% warn %}}
|
||||||
|
While the `influx` CLI may coincidentally work with InfluxDB Cloud Dedicated, it isn't officially supported.
|
||||||
|
{{% /warn %}}
|
||||||
|
|
||||||
|
The following example shows how to use the **cURL** command line tool and the InfluxDB Cloud Dedicated v2 API to write line protocol data to a database:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
curl --request POST \
|
||||||
|
"https://cluster-id.influxdb.io/api/v2/write?bucket=DATABASE_NAME&precision=ns" \
|
||||||
|
--header "Authorization: Token DATABASE_TOKEN" \
|
||||||
|
--header "Content-Type: text/plain; charset=utf-8" \
|
||||||
|
--header "Accept: application/json" \
|
||||||
|
--data-binary '
|
||||||
|
airSensors,sensor_id=TLM0201 temperature=73.97038159354763,humidity=35.23103248356096,co=0.48445310567793615 1630424257000000000
|
||||||
|
airSensors,sensor_id=TLM0202 temperature=75.30007505999716,humidity=35.651929918691714,co=0.5141876544505826 1630424257000000000'
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace the following:
|
||||||
|
|
||||||
|
- **`DATABASE_NAME`**: your InfluxDB Cloud Dedicated database
|
||||||
|
- **`DATABASE_TOKEN`**: a [database token](/influxdb/cloud-dedicated/admin/tokens/) with sufficient permissions to the database
|
||||||
|
|
||||||
|
### influx CLI not supported
|
||||||
|
|
||||||
|
Don't use the `influx` CLI with {{% cloud-name %}}.
|
||||||
|
While it may coincidentally work, it isn't officially supported.
|
||||||
|
|
||||||
|
If you need to test writes interactively, see how to [write using HTTP clients](#write-using-http-clients).
|
||||||
|
|
||||||
|
## Query data
|
||||||
|
|
||||||
|
Use Flight SQL clients with gRPC and SQL to query data stored in an InfluxDB Cloud Dedicated database.
|
||||||
|
|
||||||
|
### Query using Flight SQL
|
||||||
|
|
||||||
|
Choose from the following tools to query InfluxDB Cloud Dedicated:
|
||||||
|
|
||||||
|
- [Flight SQL plugin]() for [Grafana]()
|
||||||
|
- [Superset]()
|
||||||
|
- [`pyinflux3` module](https://github.com/InfluxCommunity/pyinflux3)
|
||||||
|
- [`flightsql-dbapi`](https://github.com/influxdata/flightsql-dbapi)
|
||||||
|
|
||||||
|
See how to [get started querying with SQL](/influxdb/cloud-dedicated/get-started/query/#sql-query-basics)
|
||||||
|
|
||||||
|
### /api/v2/query not supported
|
||||||
|
|
||||||
|
The `/api/v2/query` and associated tooling aren't supported in InfluxDB Cloud Dedicated. See how to [query using Flight SQL](#query-using-flight-sql).
|
|
@ -5,10 +5,10 @@ description: >
|
||||||
Learn to query data stored in InfluxDB using SQL, InfluxQL, and Flux using tools
|
Learn to query data stored in InfluxDB using SQL, InfluxQL, and Flux using tools
|
||||||
like the InfluxDB user interface and the 'influx' command line interface.
|
like the InfluxDB user interface and the 'influx' command line interface.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: Query data
|
name: Query data
|
||||||
weight: 4
|
weight: 4
|
||||||
influxdb/cloud-iox/tags: [query, flux]
|
influxdb/cloud-dedicated/tags: [query, flux]
|
||||||
---
|
---
|
||||||
|
|
||||||
Learn to query data stored in InfluxDB.
|
Learn to query data stored in InfluxDB.
|
|
@ -1,13 +1,13 @@
|
||||||
---
|
---
|
||||||
title: Execute queries
|
title: Execute queries
|
||||||
seotitle: Execute queries for data stored in an InfluxDB bucket powered by IOx
|
seotitle: Execute queries for data stored in an InfluxDB database
|
||||||
description: Use tools and libraries to query data stored in an InfluxDB bucket powered by IOx.
|
description: Use tools and libraries to query data stored in an InfluxDB database.
|
||||||
weight: 103
|
weight: 103
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: Execute queries
|
name: Execute queries
|
||||||
parent: Query data
|
parent: Query data
|
||||||
influxdb/cloud-iox/tags: [query]
|
influxdb/cloud-dedicated/tags: [query]
|
||||||
---
|
---
|
||||||
|
|
||||||
There are multiple ways to execute queries with InfluxDB. Choose from the following options:
|
There are multiple ways to execute queries with InfluxDB. Choose from the following options:
|
|
@ -5,20 +5,20 @@ description: >
|
||||||
Query your data using Apache Arrow Flight SQL protocol and clients.
|
Query your data using Apache Arrow Flight SQL protocol and clients.
|
||||||
weight: 201
|
weight: 201
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: Query with Flight SQL
|
name: Query with Flight SQL
|
||||||
parent: Execute queries
|
parent: Execute queries
|
||||||
influxdb/cloud-iox/tags: [query, flightsql]
|
influxdb/cloud-dedicated/tags: [query, flightsql]
|
||||||
---
|
---
|
||||||
|
|
||||||
Use [Apache Arrow Flight SQL](https://arrow.apache.org/) to query data
|
Use [Apache Arrow Flight SQL](https://arrow.apache.org/) to query data
|
||||||
stored in an InfluxDB bucket powered by InfluxDB IOx.
|
stored in an InfluxDB database.
|
||||||
|
|
||||||
> Arrow Flight SQL is a protocol for interacting with SQL databases using the [Arrow in-memory format](https://arrow.apache.org/docs/format/Columnar.html) and the [Flight RPC](https://arrow.apache.org/docs/format/Flight.html) framework.
|
> Arrow Flight SQL is a protocol for interacting with SQL databases using the [Arrow in-memory format](https://arrow.apache.org/docs/format/Columnar.html) and the [Flight RPC](https://arrow.apache.org/docs/format/Flight.html) framework.
|
||||||
>
|
>
|
||||||
> {{% caption %}}[Apache Arrow Flight SQL documentation](https://arrow.apache.org/docs/format/FlightSql.html){{% /caption %}}
|
> {{% caption %}}[Apache Arrow Flight SQL documentation](https://arrow.apache.org/docs/format/FlightSql.html){{% /caption %}}
|
||||||
|
|
||||||
Data platforms and clients that support the Flight SQL protocol can query data stored in an InfluxDB bucket powered by IOx.
|
Data platforms and clients that support the Flight SQL protocol can query data stored in an InfluxDB database.
|
||||||
Learn how to connect to InfluxDB and query your data using the following tools:
|
Learn how to connect to InfluxDB and query your data using the following tools:
|
||||||
|
|
||||||
{{< children >}}
|
{{< children >}}
|
|
@ -0,0 +1,302 @@
|
||||||
|
---
|
||||||
|
title: Use Python and the Flight SQL library to query data
|
||||||
|
description: >
|
||||||
|
Use Python and the `flightsql-dbapi` Flight SQL library to query data
|
||||||
|
stored in InfluxDB.
|
||||||
|
weight: 101
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: Query with Flight SQL
|
||||||
|
name: Use Python
|
||||||
|
identifier: query_with_python
|
||||||
|
influxdb/cloud-dedicated/tags: [query, flightsql, python]
|
||||||
|
related:
|
||||||
|
- /influxdb/cloud-dedicated/query-data/tools/pandas/
|
||||||
|
- /influxdb/cloud-dedicated/query-data/tools/pyarrow/
|
||||||
|
- /influxdb/cloud-dedicated/query-data/sql/
|
||||||
|
list_code_example: |
|
||||||
|
```py
|
||||||
|
from flightsql import FlightSQLClient
|
||||||
|
|
||||||
|
client = FlightSQLClient(host='cluster-id.influxdb.io',
|
||||||
|
token='INFLUX_READ_WRITE_TOKEN',
|
||||||
|
metadata={'iox-namespace-name': 'INFLUX_DATABASE'},
|
||||||
|
features={'metadata-reflection': 'true'})
|
||||||
|
|
||||||
|
info = client.execute("SELECT * FROM home")
|
||||||
|
|
||||||
|
ticket = info.endpoints[0].ticket
|
||||||
|
|
||||||
|
reader = client.do_get(ticket)
|
||||||
|
```
|
||||||
|
---
|
||||||
|
|
||||||
|
Use Python and the Flight SQL library to query data stored in InfluxDB.
|
||||||
|
|
||||||
|
- [Get started using Python to query InfluxDB](#get-started-using-python-to-query-influxdb)
|
||||||
|
- [Create a Python virtual environment](#create-a-python-virtual-environment)
|
||||||
|
- [Install Python](#install-python)
|
||||||
|
- [Create a project virtual environment](#venv-install)
|
||||||
|
- [Install Anaconda](#conda-install)
|
||||||
|
- [Query InfluxDB using Flight SQL](#query-influxdb-using-flight-sql)
|
||||||
|
- [Install the Flight SQL Python Library](#install-the-flight-sql-python-library)
|
||||||
|
- [Create a query client](#create-a-query-client)
|
||||||
|
- [Execute a query](#execute-a-query)
|
||||||
|
- [Retrieve data for Flight SQL query results](#retrieve-data-for-flight-sql-query-results)
|
||||||
|
|
||||||
|
## Get started using Python to query InfluxDB
|
||||||
|
|
||||||
|
This guide follows the recommended practice of using Python _virtual environments_.
|
||||||
|
If you don't want to use virtual environments and you have Python installed,
|
||||||
|
continue to [Query InfluxDB using Flight SQL](#query-influxdb-using-flight-sql).
|
||||||
|
|
||||||
|
## Create a Python virtual environment
|
||||||
|
|
||||||
|
Python [virtual environments](https://docs.python.org/3/library/venv.html) keep
|
||||||
|
the Python interpreter and dependencies for your project self-contained and isolated from other projects.
|
||||||
|
|
||||||
|
To install Python and create a virtual environment, choose one of the following options:
|
||||||
|
|
||||||
|
- [Python venv](?t=venv#venv-install): The [`venv` module](https://docs.python.org/3/library/venv.html) comes standard in Python as of version 3.5.
|
||||||
|
- [Anaconda® Distribution](?t=Anaconda#conda-install): A Python/R data science distribution that provides Python and the **conda** package and environment manager.
|
||||||
|
|
||||||
|
{{< tabs-wrapper >}}
|
||||||
|
{{% tabs "small" %}}
|
||||||
|
[venv]()
|
||||||
|
[Anaconda]()
|
||||||
|
{{% /tabs %}}
|
||||||
|
{{% tab-content %}}
|
||||||
|
<!--------------------------------- Begin venv -------------------------------->
|
||||||
|
|
||||||
|
### Install Python
|
||||||
|
|
||||||
|
1. Follow the [Python installation instructions](https://wiki.python.org/moin/BeginnersGuide/Download)
|
||||||
|
to install a recent version of the Python programming language for your system.
|
||||||
|
2. Check that you can run `python` and `pip` commands.
|
||||||
|
`pip` is a package manager included in most Python distributions.
|
||||||
|
|
||||||
|
In your terminal, enter the following commands:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python --version
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pip --version
|
||||||
|
```
|
||||||
|
|
||||||
|
Depending on your system, you may need to use version-specific commands--for example.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python3 --version
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pip3 --version
|
||||||
|
```
|
||||||
|
|
||||||
|
If neither `pip` nor `pip<PYTHON_VERSION>` works, follow one of the [Pypa.io Pip installation](https://pip.pypa.io/en/stable/installation/) methods for your system.
|
||||||
|
|
||||||
|
### Create a project virtual environment {#venv-install}
|
||||||
|
|
||||||
|
1. Create a directory for your Python project and change to the new directory--for example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mkdir ./PROJECT_DIRECTORY && cd $_
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Use the Python `venv` module to create a virtual environment--for example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python -m venv envs/virtualenv-1
|
||||||
|
```
|
||||||
|
|
||||||
|
`venv` creates the new virtual environment directory in your project.
|
||||||
|
|
||||||
|
3. To activate the new virtual environment in your terminal, run the `source` command and pass the file path of the virtual environment `activate` script:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
source envs/VIRTUAL_ENVIRONMENT_NAME/bin/activate
|
||||||
|
```
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
source envs/virtualenv-1/bin/activate
|
||||||
|
```
|
||||||
|
<!---------------------------------- End venv --------------------------------->
|
||||||
|
{{% /tab-content %}}
|
||||||
|
{{% tab-content %}}
|
||||||
|
<!-------------------------------- Begin conda -------------------------------->
|
||||||
|
|
||||||
|
### Install Anaconda {#conda-install}
|
||||||
|
|
||||||
|
1. Follow the [Anaconda installation instructions](https://docs.continuum.io/anaconda/install/) for your system.
|
||||||
|
2. Check that you can run the `conda` command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
conda
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Use `conda` to create a virtual environment--for example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
conda create --prefix envs/virtualenv-1
|
||||||
|
```
|
||||||
|
|
||||||
|
`conda` creates a virtual environment in a directory named `./envs/virtualenv-1`.
|
||||||
|
|
||||||
|
4. To activate the new virtual environment, use the `conda activate` command and pass the directory path of the virtual environment:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
conda activate envs/VIRTUAL_ENVIRONMENT_NAME
|
||||||
|
```
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
conda activate ./envs/virtualenv-1
|
||||||
|
```
|
||||||
|
|
||||||
|
<!--------------------------------- END conda --------------------------------->
|
||||||
|
{{% /tab-content %}}
|
||||||
|
{{< /tabs-wrapper >}}
|
||||||
|
|
||||||
|
When a virtual environment is activated, the name displays at the beginning of your terminal command line--for example:
|
||||||
|
|
||||||
|
{{% code-callout "(virtualenv-1)"%}}
|
||||||
|
```sh
|
||||||
|
(virtualenv-1) $ PROJECT_DIRECTORY
|
||||||
|
```
|
||||||
|
{{% /code-callout %}}
|
||||||
|
|
||||||
|
## Query InfluxDB using Flight SQL
|
||||||
|
|
||||||
|
1. [Install the Flight SQL Python Library](#install-the-flight-sql-python-library)
|
||||||
|
2. [Create a query client](#create-a-query-client)
|
||||||
|
3. [Execute a query](#execute-a-query)
|
||||||
|
|
||||||
|
### Install the Flight SQL Python Library
|
||||||
|
|
||||||
|
The [`flightsql-dbapi`](https://github.com/influxdata/flightsql-dbapi) Flight SQL library for Python provides a
|
||||||
|
[DB API 2](https://peps.python.org/pep-0249/) interface and
|
||||||
|
[SQLAlchemy](https://www.sqlalchemy.org/) dialect for
|
||||||
|
[Flight SQL](https://arrow.apache.org/docs/format/FlightSql.html).
|
||||||
|
Installing `flightsql-dbapi` also installs the [`pyarrow`](https://arrow.apache.org/docs/python/index.html) library that you'll use for working with Arrow data.
|
||||||
|
|
||||||
|
In your terminal, use `pip` to install `flightsql-dbapi`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pip install flightsql-dbapi
|
||||||
|
```
|
||||||
|
|
||||||
|
With `flightsql-dbapi` and `pyarrow` installed, you're ready to query and analyze data stored in an InfluxDB database.
|
||||||
|
|
||||||
|
### Create a query client
|
||||||
|
|
||||||
|
The following example shows how to use Python with `flightsql-dbapi`
|
||||||
|
and the _DB API 2_ interface to instantiate a Flight SQL client configured for an InfluxDB database.
|
||||||
|
|
||||||
|
1. In your editor, copy and paste the following sample code to a new file--for example, `query-example.py`:
|
||||||
|
|
||||||
|
```py
|
||||||
|
# query-example.py
|
||||||
|
|
||||||
|
from flightsql import FlightSQLClient
|
||||||
|
|
||||||
|
# Instantiate a FlightSQLClient configured for your database
|
||||||
|
client = FlightSQLClient(host='cluster-id.influxdb.io',
|
||||||
|
token='INFLUX_READ_WRITE_TOKEN',
|
||||||
|
metadata={'iox-namespace-name': 'INFLUX_DATABASE'},
|
||||||
|
features={'metadata-reflection': 'true'})
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Replace the following configuration values:
|
||||||
|
|
||||||
|
- **`INFLUX_READ_WRITE_TOKEN`**: Your InfluxDB token with read permissions on the databases you want to query.
|
||||||
|
- **`INFLUX_DATABASE`**: The name of your InfluxDB database.
|
||||||
|
|
||||||
|
### Execute a query
|
||||||
|
|
||||||
|
To execute an SQL query, call the query client's `execute(query)` method and pass the query as a string.
|
||||||
|
|
||||||
|
#### Syntax {#execute-query-syntax}
|
||||||
|
|
||||||
|
```py
|
||||||
|
execute(query: str, call_options: Optional[FlightSQLCallOptions] = None)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Example {#execute-query-example}
|
||||||
|
|
||||||
|
```py
|
||||||
|
# query-example.py
|
||||||
|
|
||||||
|
from flightsql import FlightSQLClient
|
||||||
|
|
||||||
|
client = FlightSQLClient(host='cluster-id.influxdb.io',
|
||||||
|
token='INFLUX_READ_WRITE_TOKEN',
|
||||||
|
metadata={'iox-namespace-name': 'INFLUX_DATABASE'},
|
||||||
|
features={'metadata-reflection': 'true'})
|
||||||
|
|
||||||
|
# Execute the query
|
||||||
|
info = client.execute("SELECT * FROM home")
|
||||||
|
```
|
||||||
|
|
||||||
|
The response contains a `flight.FlightInfo` object that contains metadata and an `endpoints: [...]` list. Each endpoint contains the following:
|
||||||
|
|
||||||
|
- A list of addresses where you can retrieve the data.
|
||||||
|
- A `ticket` value that identifies the data to retrieve.
|
||||||
|
|
||||||
|
Next, use the ticket to [retrieve data for Flight SQL query results](#retrieve-data-for-flight-sql-query-results)
|
||||||
|
|
||||||
|
### Retrieve data for Flight SQL query results
|
||||||
|
|
||||||
|
To retrieve Arrow data for a query result, call the client's `do_get(ticket)` method.
|
||||||
|
|
||||||
|
#### Syntax {#retrieve-data-syntax}
|
||||||
|
|
||||||
|
```py
|
||||||
|
do_get(ticket, call_options: Optional[FlightSQLCallOptions] = None)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Example {#retrieve-data-example}
|
||||||
|
|
||||||
|
The following sample shows how to use Python with `flightsql-dbapi` and `pyarrow` to query InfluxDB and retrieve data.
|
||||||
|
|
||||||
|
```py
|
||||||
|
# query-example.py
|
||||||
|
|
||||||
|
from flightsql import FlightSQLClient
|
||||||
|
|
||||||
|
# Instantiate a FlightSQLClient configured for a database
|
||||||
|
client = FlightSQLClient(host='cluster-id.influxdb.io',
|
||||||
|
token='INFLUX_READ_WRITE_TOKEN',
|
||||||
|
metadata={'iox-namespace-name': 'INFLUX_DATABASE'},
|
||||||
|
features={'metadata-reflection': 'true'})
|
||||||
|
|
||||||
|
# Execute the query to retrieve FlightInfo
|
||||||
|
info = client.execute("SELECT * FROM home")
|
||||||
|
|
||||||
|
# Extract the token for retrieving data
|
||||||
|
ticket = info.endpoints[0].ticket
|
||||||
|
|
||||||
|
# Use the ticket to request the Arrow data stream.
|
||||||
|
# Return a FlightStreamReader for streaming the results.
|
||||||
|
reader = client.do_get(ticket)
|
||||||
|
|
||||||
|
# Read all data to a pyarrow.Table
|
||||||
|
table = reader.read_all()
|
||||||
|
```
|
||||||
|
|
||||||
|
`do_get(ticket)` returns a [`pyarrow.flight.FlightStreamReader`](https://arrow.apache.org/docs/python/generated/pyarrow.flight.FlightStreamReader.html) for streaming Arrow [record batches](https://arrow.apache.org/docs/python/data.html#record-batches).
|
||||||
|
|
||||||
|
To read data from the stream, call one of the following `FlightStreamReader` methods:
|
||||||
|
|
||||||
|
- `read_all()`: Read all record batches as a [`pyarrow.Table`](https://arrow.apache.org/docs/python/generated/pyarrow.Table.html).
|
||||||
|
- `read_chunk()`: Read the next RecordBatch and metadata.
|
||||||
|
- `read_pandas()`: Read all record batches and convert them to a [`pandas.DataFrame`](https://pandas.pydata.org/docs/reference/frame.html).
|
||||||
|
|
||||||
|
Next, learn how to use Python tools to work with time series data:
|
||||||
|
|
||||||
|
- [Use PyArrow](/influxdb/cloud-dedicated/query-data/tools/pyarrow/)
|
||||||
|
- [Use pandas](/influxdb/cloud-dedicated/query-data/tools/pandas/)
|
|
@ -0,0 +1,258 @@
|
||||||
|
---
|
||||||
|
title: Use Superset to query data
|
||||||
|
seotitle: Use Apache Superset to query data stored in InfluxDB Cloud (IOx)
|
||||||
|
description: >
|
||||||
|
Install and run [Apache Superset](https://superset.apache.org/)
|
||||||
|
to query data stored in InfluxDB.
|
||||||
|
weight: 101
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: Query with Flight SQL
|
||||||
|
name: Use Superset
|
||||||
|
identifier: query_with_superset
|
||||||
|
influxdb/cloud-dedicated/tags: [query, flightsql, superset]
|
||||||
|
related:
|
||||||
|
- /influxdb/cloud-dedicated/visualize-data/superset/
|
||||||
|
---
|
||||||
|
|
||||||
|
Use [Apache Superset](https://superset.apache.org/) to query data
|
||||||
|
stored in an InfluxDB database.
|
||||||
|
|
||||||
|
> Apache Superset is a modern, enterprise-ready business intelligence web application.
|
||||||
|
> It is fast, lightweight, intuitive, and loaded with options that make it easy for
|
||||||
|
> users of all skill sets to explore and visualize their data, from simple pie
|
||||||
|
> charts to highly detailed deck.gl geospatial charts.
|
||||||
|
>
|
||||||
|
> {{% cite %}}-- [Apache Superset documentation](https://superset.apache.org/docs/intro){{% /cite %}}
|
||||||
|
|
||||||
|
<!-- TOC -->
|
||||||
|
|
||||||
|
- [Set up Docker for Superset and Flight SQL](#set-up-docker-for-superset-and-flight-sql)
|
||||||
|
- [Install prerequisites for Superset and Flight SQL](#install-prerequisites-for-superset-and-flight-sql)
|
||||||
|
- [Set up Docker for Superset](#set-up-docker-for-superset)
|
||||||
|
- [Start the Superset Docker containers](#start-the-superset-docker-containers)
|
||||||
|
- [Log in to Superset](#log-in-to-superset)
|
||||||
|
- [Create a database connection for InfluxDB](#create-a-database-connection-for-influxdb)
|
||||||
|
- [Query InfluxDB with Superset](#query-influxdb-with-superset)
|
||||||
|
|
||||||
|
<!-- /TOC -->
|
||||||
|
|
||||||
|
## Set up Docker for Superset and Flight SQL
|
||||||
|
|
||||||
|
### Install prerequisites for Superset and Flight SQL
|
||||||
|
|
||||||
|
We recommend using **Docker and docker-compose** to run Superset.
|
||||||
|
To set up Superset to run in Docker containers with Flight SQL, follow these steps:
|
||||||
|
|
||||||
|
{{% warn %}}
|
||||||
|
**Superset** is not officially supported on Windows. For more information about running Superset with
|
||||||
|
Windows and Docker, see the
|
||||||
|
[Superset documentation](https://superset.apache.org/docs/installation/installing-superset-using-docker-compose#1-install-a-docker-engine-and-docker-compose).
|
||||||
|
{{% /warn %}}
|
||||||
|
|
||||||
|
1. Follow the instructions to download and install Docker and docker-compose for your system:
|
||||||
|
|
||||||
|
- **macOS**: [Install Docker for macOS](https://docs.docker.com/desktop/install/mac-install/)
|
||||||
|
- **Linux**: [Install Docker for Linux](https://docs.docker.com/desktop/install/linux-install/)
|
||||||
|
|
||||||
|
2. Follow the [Python.org Downloading Python](https://wiki.python.org/moin/BeginnersGuide/Download) instructions for your system.
|
||||||
|
|
||||||
|
3. Once you've installed Python, check that you can run Python and Pip.
|
||||||
|
Depending on your system, you may need to use the Python version 3 (`python3` and `pip3`) commands.
|
||||||
|
Enter the following commands into your terminal:
|
||||||
|
|
||||||
|
{{< code-tabs-wrapper >}}
|
||||||
|
{{% code-tabs %}}
|
||||||
|
[python](#)
|
||||||
|
[python3](#)
|
||||||
|
{{% /code-tabs %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
```sh
|
||||||
|
python --version
|
||||||
|
```
|
||||||
|
```sh
|
||||||
|
pip --version
|
||||||
|
```
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
```sh
|
||||||
|
python3 --version
|
||||||
|
```
|
||||||
|
```sh
|
||||||
|
pip3 --version
|
||||||
|
```
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{< /code-tabs-wrapper >}}
|
||||||
|
|
||||||
|
If neither `pip` nor `pip3` works, follow one of the [Pypa.io Pip Installation](https://pip.pypa.io/en/stable/installation/) methods for your system.
|
||||||
|
|
||||||
|
3. Use Pip to install the `flightsql-dbapi` library.
|
||||||
|
|
||||||
|
{{< code-tabs-wrapper >}}
|
||||||
|
{{% code-tabs %}}
|
||||||
|
[pip](#)
|
||||||
|
[pip3](#)
|
||||||
|
{{% /code-tabs %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
```sh
|
||||||
|
pip install flightsql-dbapi
|
||||||
|
```
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
```sh
|
||||||
|
pip3 install flightsql-dbapi
|
||||||
|
```
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{< /code-tabs-wrapper >}}
|
||||||
|
|
||||||
|
The `flightsql-dbapi` library for Python provides a
|
||||||
|
[DB API 2](https://peps.python.org/pep-0249/) interface and
|
||||||
|
[SQLAlchemy](https://www.sqlalchemy.org/) dialect for
|
||||||
|
[Flight SQL](https://arrow.apache.org/docs/format/FlightSql.html).
|
||||||
|
Later, you'll add `flightsql-dbapi` to Superset's Docker configuration.
|
||||||
|
|
||||||
|
{{% warn %}}
|
||||||
|
The `flightsql-dbapi` library is experimental and under active development.
|
||||||
|
The APIs it provides could change at any time.
|
||||||
|
{{% /warn %}}
|
||||||
|
|
||||||
|
4. Use Git to clone the Apache Superset repository:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git clone https://github.com/apache/superset.git
|
||||||
|
```
|
||||||
|
|
||||||
|
The repository contains Superset code and configuration files for running Superset in Docker containers.
|
||||||
|
|
||||||
|
### Set up Docker for Superset
|
||||||
|
|
||||||
|
1. Change to your **superset** repository directory:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd ./superset
|
||||||
|
```
|
||||||
|
|
||||||
|
2. In your text editor or terminal, create the file `./docker/requirements-local.txt` and append the line `flightsql-dbapi`--for example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cat <<EOF >./docker/requirements-local.txt
|
||||||
|
flightsql-dbapi
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
|
||||||
|
The `./docker/requirements-local.txt` file is used to specify additional Python packages that Docker should include for Superset.
|
||||||
|
For more information about Superset's Docker configuration, see [Getting Started with Superset using Docker](https://github.com/apache/superset/tree/master/docker#readme).
|
||||||
|
3. Use the `docker-compose pull` command to fetch dependencies for the Docker containers.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker-compose -f docker-compose-non-dev.yml pull
|
||||||
|
```
|
||||||
|
|
||||||
|
The process might take several seconds to complete.
|
||||||
|
After it completes, you're ready to [Start the Superset Docker containers](#start-the-superset-docker-containers).
|
||||||
|
|
||||||
|
## Start the Superset Docker containers
|
||||||
|
|
||||||
|
To start the containers and run Superset, enter the `docker-compose up` command and pass the `-f` flag with the setup file name:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker-compose -f docker-compose-non-dev.yml up
|
||||||
|
```
|
||||||
|
|
||||||
|
This might take several seconds to complete.
|
||||||
|
|
||||||
|
If successful, the terminal contains output similar to the following:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
superset_init | Init Step 4/4 [Complete] -- Loading examples
|
||||||
|
superset_init |
|
||||||
|
superset_init |
|
||||||
|
superset_init | ######################################################################
|
||||||
|
superset_init |
|
||||||
|
superset_init exited with code 0
|
||||||
|
superset_app | 127.0.0.1 - - [24/Mar/2023:15:14:11 +0000] "GET /health HTTP/1.1" 200 2 "-" "curl/7.74.0"
|
||||||
|
```
|
||||||
|
|
||||||
|
With Superset running, you're ready to [log in](#log-in-to-superset) and set up a database connection.
|
||||||
|
|
||||||
|
## Log in to Superset
|
||||||
|
|
||||||
|
1. In a browser, visit [localhost:8088](http://localhost:8088) to log in to the Superset user interface (UI).
|
||||||
|
If you configured Superset to use a custom domain, navigate to your custom domain.
|
||||||
|
|
||||||
|
2. If this is your first time logging into Superset, use the following username
|
||||||
|
and password:
|
||||||
|
|
||||||
|
- **Username**: admin
|
||||||
|
- **Password**: admin
|
||||||
|
|
||||||
|
3. Optional: Create a new admin user with a unique password.
|
||||||
|
|
||||||
|
1. In the Superset UI, click **Settings** in the top right
|
||||||
|
and select **List Users**.
|
||||||
|
2. Click **{{< icon "plus" >}}** in the top right.
|
||||||
|
3. Select the **Admin** role and provide the remaining credentials for the new user.
|
||||||
|
4. Click **Save**.
|
||||||
|
5. Delete the default **admin** users.
|
||||||
|
|
||||||
|
## Create a database connection for InfluxDB
|
||||||
|
|
||||||
|
1. In the Superset UI, click **Settings** in the top right and select
|
||||||
|
**Database Connections**.
|
||||||
|
2. Click **+ Database** in the top right.
|
||||||
|
3. In the **Connect a Database** window, click on the **Supported Databases**
|
||||||
|
drop-down menu and select **Other**.
|
||||||
|
|
||||||
|
{{< img-hd src="/img/influxdb/cloud-serverless-superset-connect.png" alt="Configure InfluxDB connection in Superset" />}}
|
||||||
|
|
||||||
|
4. Enter a **Display Name** (for example, _InfluxDB Cloud IOx_) for the database connection.
|
||||||
|
5. Enter your **SQL Alchemy URI** comprised of the following:
|
||||||
|
|
||||||
|
- **Protocol**: `datafusion+flightsql`
|
||||||
|
- **Domain**: InfluxDB Cloud dedicated cluster URL
|
||||||
|
- **Port**: 443
|
||||||
|
|
||||||
|
**Query parameters**
|
||||||
|
|
||||||
|
- **`?iox-namespace-name`**: URL-encoded InfluxDB [database name](/influxdb/cloud-dedicated/admin/databases/list/)
|
||||||
|
- **`?token`**: InfluxDB [API token](/influxdb/cloud-dedicated/get-started/setup/) with `READ` access to the specified database
|
||||||
|
|
||||||
|
{{< code-callout "<(domain|port|database-name|token)>" >}}
|
||||||
|
{{< code-callout "cluster-id\.influxdb\.io|443|example-database|example-token" >}}
|
||||||
|
```sh
|
||||||
|
# Syntax
|
||||||
|
datafusion+flightsql://<domain>:<port>?iox-namespace-name=<database-name>&token=<token>
|
||||||
|
|
||||||
|
# Example
|
||||||
|
datafusion+flightsql://cluster-id.influxdb.io:443?iox-namespace-name=example-database&token=example-token
|
||||||
|
```
|
||||||
|
{{< /code-callout >}}
|
||||||
|
{{< /code-callout >}}
|
||||||
|
|
||||||
|
6. Click **Test Connection** to ensure the connection works.
|
||||||
|
7. Click **Connect** to save the database connection.
|
||||||
|
|
||||||
|
## Query InfluxDB with Superset
|
||||||
|
|
||||||
|
With a connection to InfluxDB {{< current-version >}} established, you can begin
|
||||||
|
to query and visualize data from InfluxDB.
|
||||||
|
|
||||||
|
1. In the Superset UI, click **SQL ▾** in the top navigation bar and select **SQL Lab**.
|
||||||
|
2. In the left pane:
|
||||||
|
|
||||||
|
1. Under **Database**, select your InfluxDB connection.
|
||||||
|
2. Under **Schema**, select **iox**.
|
||||||
|
3. Under **See table schema**, select the InfluxDB measurement to query.
|
||||||
|
|
||||||
|
The measurement schema appears in the left pane:
|
||||||
|
|
||||||
|
{{< img-hd src="/img/influxdb/cloud-serverless-superset-schema.png" alt="Select your InfluxDB schema in Superset" />}}
|
||||||
|
|
||||||
|
3. Use the **query editor** to write an SQL query that queries data in your
|
||||||
|
InfluxDB database.
|
||||||
|
4. Click **Run** to execute the query.
|
||||||
|
|
||||||
|
Query results appear below the query editor.
|
||||||
|
|
||||||
|
With a connection to InfluxDB {{< current-version >}} established and a query
|
||||||
|
that returns results, you're ready to [visualize data using Superset](/influxdb/cloud-dedicated/visualize-data/superset/).
|
|
@ -4,11 +4,11 @@ seotitle: Query data with SQL
|
||||||
description: >
|
description: >
|
||||||
Learn to query data stored in InfluxDB Cloud using SQL.
|
Learn to query data stored in InfluxDB Cloud using SQL.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: Query with SQL
|
name: Query with SQL
|
||||||
parent: Query data
|
parent: Query data
|
||||||
weight: 101
|
weight: 101
|
||||||
influxdb/cloud-iox/tags: [query, sql]
|
influxdb/cloud-dedicated/tags: [query, sql]
|
||||||
---
|
---
|
||||||
|
|
||||||
Learn to query data stored in InfluxDB using SQL.
|
Learn to query data stored in InfluxDB using SQL.
|
|
@ -5,15 +5,15 @@ description: >
|
||||||
Use aggregate and selector functions to perform aggregate operations on your
|
Use aggregate and selector functions to perform aggregate operations on your
|
||||||
time series data.
|
time series data.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: Aggregate data
|
name: Aggregate data
|
||||||
parent: Query with SQL
|
parent: Query with SQL
|
||||||
identifier: query-sql-aggregate
|
identifier: query-sql-aggregate
|
||||||
weight: 203
|
weight: 203
|
||||||
influxdb/cloud-iox/tags: [query, sql]
|
influxdb/cloud-dedicated/tags: [query, sql]
|
||||||
related:
|
related:
|
||||||
- /influxdb/cloud-iox/reference/sql/functions/aggregate/
|
- /influxdb/cloud-dedicated/reference/sql/functions/aggregate/
|
||||||
- /influxdb/cloud-iox/reference/sql/functions/selector/
|
- /influxdb/cloud-dedicated/reference/sql/functions/selector/
|
||||||
list_code_example: |
|
list_code_example: |
|
||||||
##### Aggregate fields by groups
|
##### Aggregate fields by groups
|
||||||
```sql
|
```sql
|
||||||
|
@ -75,7 +75,7 @@ value of `room`.
|
||||||
Use **aggregate functions** to aggregate values in a specified column for each
|
Use **aggregate functions** to aggregate values in a specified column for each
|
||||||
group and return a single row per group containing the aggregate value.
|
group and return a single row per group containing the aggregate value.
|
||||||
|
|
||||||
[View aggregate functions](/influxdb/cloud-iox/reference/sql/functions/aggregate/)
|
[View aggregate functions](/influxdb/cloud-dedicated/reference/sql/functions/aggregate/)
|
||||||
|
|
||||||
##### Basic aggregate query
|
##### Basic aggregate query
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ SELECT AVG(co) from home
|
||||||
Use **selector functions** to "select" a value from a specified column.
|
Use **selector functions** to "select" a value from a specified column.
|
||||||
The available selector functions are designed to work with time series data.
|
The available selector functions are designed to work with time series data.
|
||||||
|
|
||||||
[View selector functions](/influxdb/cloud-iox/reference/sql/functions/selector/)
|
[View selector functions](/influxdb/cloud-dedicated/reference/sql/functions/selector/)
|
||||||
|
|
||||||
Each selector function returns a Rust _struct_ (similar to a JSON object)
|
Each selector function returns a Rust _struct_ (similar to a JSON object)
|
||||||
representing a single time and value from the specified column in the each group.
|
representing a single time and value from the specified column in the each group.
|
||||||
|
@ -138,10 +138,10 @@ GROUP BY room
|
||||||
#### Sample data
|
#### Sample data
|
||||||
|
|
||||||
The following examples use the sample data written in the
|
The following examples use the sample data written in the
|
||||||
[Get started writing data guide](/influxdb/cloud-iox/get-started/write/).
|
[Get started writing data guide](/influxdb/cloud-dedicated/get-started/write/).
|
||||||
To run the example queries and return results,
|
To run the example queries and return results,
|
||||||
[write the sample data](/influxdb/cloud-iox/get-started/write/#write-line-protocol-to-influxdb)
|
[write the sample data](/influxdb/cloud-dedicated/get-started/write/#write-line-protocol-to-influxdb)
|
||||||
to your InfluxDB Cloud bucket before running the example queries.
|
to your InfluxDB Cloud dedicated database before running the example queries.
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
### Perform an ungrouped aggregation
|
### Perform an ungrouped aggregation
|
||||||
|
@ -201,7 +201,7 @@ groups:
|
||||||
|
|
||||||
- In your `SELECT` clause:
|
- In your `SELECT` clause:
|
||||||
|
|
||||||
- Use the [`DATE_BIN` function](/influxdb/cloud-iox/reference/sql/functions/time-and-date/#date_bin)
|
- Use the [`DATE_BIN` function](/influxdb/cloud-dedicated/reference/sql/functions/time-and-date/#date_bin)
|
||||||
to calculate time intervals and output a column that contains the start of the interval nearest to the `time` timestamp in each row--for example,
|
to calculate time intervals and output a column that contains the start of the interval nearest to the `time` timestamp in each row--for example,
|
||||||
the following clause calculates two-hour intervals starting at `1970-01-01T00:00:00Z` and returns a new `time` column that contains the start of the interval
|
the following clause calculates two-hour intervals starting at `1970-01-01T00:00:00Z` and returns a new `time` column that contains the start of the interval
|
||||||
nearest to `home.time`:
|
nearest to `home.time`:
|
||||||
|
@ -216,11 +216,11 @@ groups:
|
||||||
{{% influxdb/custom-timestamps-span %}}`2023-03-09T13:00:50.000Z`{{% /influxdb/custom-timestamps-span %}},
|
{{% influxdb/custom-timestamps-span %}}`2023-03-09T13:00:50.000Z`{{% /influxdb/custom-timestamps-span %}},
|
||||||
the output `time` column contains
|
the output `time` column contains
|
||||||
{{% influxdb/custom-timestamps-span %}}`2023-03-09T12:00:00.000Z`{{% /influxdb/custom-timestamps-span %}}.
|
{{% influxdb/custom-timestamps-span %}}`2023-03-09T12:00:00.000Z`{{% /influxdb/custom-timestamps-span %}}.
|
||||||
- Use [aggregate](/influxdb/cloud-iox/reference/sql/functions/aggregate/) or [selector](/influxdb/cloud-iox/reference/sql/functions/selector/) functions on specified columns.
|
- Use [aggregate](/influxdb/cloud-dedicated/reference/sql/functions/aggregate/) or [selector](/influxdb/cloud-dedicated/reference/sql/functions/selector/) functions on specified columns.
|
||||||
|
|
||||||
- In your `GROUP BY` clause:
|
- In your `GROUP BY` clause:
|
||||||
|
|
||||||
- Use the [`DATE_BIN` function](/influxdb/cloud-iox/reference/sql/functions/time-and-date/#date_bin) with the same parameters used in the `SELECT` clause.
|
- Use the [`DATE_BIN` function](/influxdb/cloud-dedicated/reference/sql/functions/time-and-date/#date_bin) with the same parameters used in the `SELECT` clause.
|
||||||
- Specify other columns (for example, `room`) that are specified in the `SELECT` clause and aren't used in a selector function.
|
- Specify other columns (for example, `room`) that are specified in the `SELECT` clause and aren't used in a selector function.
|
||||||
|
|
||||||
```sql
|
```sql
|
|
@ -0,0 +1,194 @@
|
||||||
|
---
|
||||||
|
title: Perform a basic SQL query
|
||||||
|
seotitle: Perform a basic SQL query in InfluxDB Cloud
|
||||||
|
description: >
|
||||||
|
A basic SQL query that queries data from InfluxDB most commonly includes
|
||||||
|
`SELECT`, `FROM`, and `WHERE` clauses.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Basic query
|
||||||
|
parent: Query with SQL
|
||||||
|
identifier: query-sql-basic
|
||||||
|
weight: 202
|
||||||
|
influxdb/cloud-dedicated/tags: [query, sql]
|
||||||
|
list_code_example: |
|
||||||
|
```sql
|
||||||
|
SELECT temp, room FROM home WHERE time >= now() - INTERVAL '1 day'
|
||||||
|
```
|
||||||
|
---
|
||||||
|
|
||||||
|
The InfluxDB SQL implementation is powered by the [Apache Arrow DataFusion](https://arrow.apache.org/datafusion/)
|
||||||
|
query engine which provides a SQL syntax similar to other relational query languages.
|
||||||
|
|
||||||
|
A basic SQL query that queries data from InfluxDB most commonly includes the
|
||||||
|
following clauses:
|
||||||
|
|
||||||
|
{{< req type="key" >}}
|
||||||
|
|
||||||
|
- {{< req "\*">}} `SELECT`: Specify fields, tags, and calculations to output from a
|
||||||
|
measurement or use the wild card alias (`*`) to select all fields and tags
|
||||||
|
from a measurement.
|
||||||
|
- {{< req "\*">}} `FROM`: Specify the measurement to query data from.
|
||||||
|
- `WHERE`: Only return data that meets the specified conditions--for example, falls within
|
||||||
|
a time range, contains specific tag values, or contains a field value outside a specified range.
|
||||||
|
|
||||||
|
{{% influxdb/custom-timestamps %}}
|
||||||
|
```sql
|
||||||
|
SELECT
|
||||||
|
temp,
|
||||||
|
hum,
|
||||||
|
room
|
||||||
|
FROM home
|
||||||
|
WHERE
|
||||||
|
time >= '2022-01-01T08:00:00Z'
|
||||||
|
AND time <= '2022-01-01T20:00:00Z'
|
||||||
|
```
|
||||||
|
{{% /influxdb/custom-timestamps %}}
|
||||||
|
|
||||||
|
## Basic query examples
|
||||||
|
|
||||||
|
- [Query data within time boundaries](#query-data-within-time-boundaries)
|
||||||
|
- [Query data without time boundaries](#query-data-without-time-boundaries)
|
||||||
|
- [Query specific fields and tags](#query-specific-fields-and-tags)
|
||||||
|
- [Query fields based on tag values](#query-fields-based-on-tag-values)
|
||||||
|
- [Query points based on field values](#query-points-based-on-field-values)
|
||||||
|
- [Alias queried fields and tags](#alias-queried-fields-and-tags)
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
#### Sample data
|
||||||
|
|
||||||
|
The following examples use the sample data written in the
|
||||||
|
[Get started writing data guide](/influxdb/cloud-dedicated/get-started/write/).
|
||||||
|
To run the example queries and return results,
|
||||||
|
[write the sample data](/influxdb/cloud-dedicated/get-started/write/#write-line-protocol-to-influxdb)
|
||||||
|
to your InfluxDB Cloud dedicated database before running the example queries.
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
|
### Query data within time boundaries
|
||||||
|
|
||||||
|
- Use the `SELECT` clause to specify what tags and fields to return.
|
||||||
|
To return all tags and fields, use the wildcard alias (`*`).
|
||||||
|
- Specify the measurement to query in the `FROM` clause.
|
||||||
|
- Specify time boundaries in the `WHERE` clause.
|
||||||
|
Include time-based predicates that compare the value of the `time` column to a timestamp.
|
||||||
|
Use the `AND` logical operator to chain multiple predicates together.
|
||||||
|
|
||||||
|
{{% influxdb/custom-timestamps %}}
|
||||||
|
```sql
|
||||||
|
SELECT *
|
||||||
|
FROM home
|
||||||
|
WHERE
|
||||||
|
time >= '2022-01-01T08:00:00Z'
|
||||||
|
AND time <= '2022-01-01T12:00:00Z'
|
||||||
|
```
|
||||||
|
{{% /influxdb/custom-timestamps %}}
|
||||||
|
|
||||||
|
Query time boundaries can be relative or absolute.
|
||||||
|
|
||||||
|
{{< expand-wrapper >}}
|
||||||
|
{{% expand "Query with relative time boundaries" %}}
|
||||||
|
|
||||||
|
To query data from relative time boundaries, compare the value of the `time`
|
||||||
|
column to a timestamp calculated by subtracting an interval from a timestamp.
|
||||||
|
Use `now()` to return the timestamp for the current time (UTC).
|
||||||
|
|
||||||
|
##### Query all data from the last month
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT * FROM home WHERE time >= now() - INTERVAL '1 month'
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Query one day of data data from a week ago
|
||||||
|
```sql
|
||||||
|
SELECT *
|
||||||
|
FROM home
|
||||||
|
WHERE
|
||||||
|
time >= now() - INTERVAL '7 days'
|
||||||
|
AND time <= now() - INTERVAL '6 days'
|
||||||
|
```
|
||||||
|
{{% /expand %}}
|
||||||
|
|
||||||
|
{{% expand "Query with absolute time boundaries" %}}
|
||||||
|
|
||||||
|
To query data from absolute time boundaries, compare the value of the `time column
|
||||||
|
to a timestamp literals.
|
||||||
|
Use the `AND` logical operator to chain together multiple predicates and define
|
||||||
|
both start and stop boundaries for the query.
|
||||||
|
|
||||||
|
{{% influxdb/custom-timestamps %}}
|
||||||
|
```sql
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
home
|
||||||
|
WHERE
|
||||||
|
time >= '2022-01-01T08:00:00Z'
|
||||||
|
AND time <= '2022-01-01T20:00:00Z'
|
||||||
|
```
|
||||||
|
{{% /influxdb/custom-timestamps %}}
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
{{< /expand-wrapper >}}
|
||||||
|
|
||||||
|
### Query data without time boundaries
|
||||||
|
|
||||||
|
To query data without time boundaries, do not include any time-based predicates
|
||||||
|
in your `WHERE` clause.
|
||||||
|
|
||||||
|
{{% warn %}}
|
||||||
|
Querying data _without time bounds_ can return an unexpected amount of data.
|
||||||
|
The query may take a long time to complete and results may be truncated.
|
||||||
|
{{% /warn %}}
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT * FROM home
|
||||||
|
```
|
||||||
|
|
||||||
|
### Query specific fields and tags
|
||||||
|
|
||||||
|
To query specific fields, include them in the `SELECT` clause.
|
||||||
|
If querying multiple fields or tags, comma-delimit each.
|
||||||
|
If the field or tag keys include special characters or spaces or are case-sensitive,
|
||||||
|
wrap the key in _double-quotes_.
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT time, room, temp, hum FROM home
|
||||||
|
```
|
||||||
|
|
||||||
|
### Query fields based on tag values
|
||||||
|
|
||||||
|
- Include the fields you want to query and the tags you want to base conditions
|
||||||
|
on in the `SELECT` clause.
|
||||||
|
- Include predicates in the `WHERE` clause that compare the tag identifier to
|
||||||
|
a string literal.
|
||||||
|
Use [logical operators](#) to chain multiple predicates together and apply
|
||||||
|
multiple conditions.
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT * FROM home WHERE room = 'Kitchen'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Query points based on field values
|
||||||
|
|
||||||
|
- Include the fields you want to query in the `SELECT` clause.
|
||||||
|
- Include predicates in the `WHERE` clause that compare the field identifier to
|
||||||
|
another value.
|
||||||
|
Use [logical operators](#) (`AND`, `OR`) to chain multiple predicates together
|
||||||
|
and apply multiple conditions.
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT co, time FROM home WHERE co >= 10 OR co <= -10
|
||||||
|
```
|
||||||
|
|
||||||
|
### Alias queried fields and tags
|
||||||
|
|
||||||
|
To alias or rename fields and tags that you query, pass a string literal after
|
||||||
|
the field or tag identifier in the `SELECT` clause.
|
||||||
|
You can use the `AS` clause to define the alias, but it isn't necessary.
|
||||||
|
The following queries are functionally the same:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT temp 'temperature', hum 'humidity' FROM home
|
||||||
|
|
||||||
|
SELECT temp AS 'temperature', hum AS 'humidity' FROM home
|
||||||
|
```
|
|
@ -5,14 +5,14 @@ description: >
|
||||||
Use the `CAST` function or double-colon `::` casting shorthand syntax to cast
|
Use the `CAST` function or double-colon `::` casting shorthand syntax to cast
|
||||||
a value to a specific type.
|
a value to a specific type.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: Cast types
|
name: Cast types
|
||||||
parent: Query with SQL
|
parent: Query with SQL
|
||||||
identifier: query-sql-cast-types
|
identifier: query-sql-cast-types
|
||||||
weight: 205
|
weight: 205
|
||||||
influxdb/cloud-iox/tags: [query, sql]
|
influxdb/cloud-dedicated/tags: [query, sql]
|
||||||
related:
|
related:
|
||||||
- /influxdb/cloud-iox/reference/sql/data-types/
|
- /influxdb/cloud-dedicated/reference/sql/data-types/
|
||||||
list_code_example: |
|
list_code_example: |
|
||||||
```sql
|
```sql
|
||||||
-- CAST clause
|
-- CAST clause
|
||||||
|
@ -44,7 +44,7 @@ SELECT 1234.5::BIGINT
|
||||||
|
|
||||||
Casting operations can be performed on a column expression or a literal value.
|
Casting operations can be performed on a column expression or a literal value.
|
||||||
For example, the following query uses the
|
For example, the following query uses the
|
||||||
[get started sample data](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)
|
[get started sample data](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)
|
||||||
and:
|
and:
|
||||||
|
|
||||||
- Casts all values in the `time` column to integers (Unix nanosecond timestamps).
|
- Casts all values in the `time` column to integers (Unix nanosecond timestamps).
|
||||||
|
@ -193,7 +193,7 @@ SQL supports casting the following to an integer:
|
||||||
- **Unsigned integers**: Returns the signed integer equivalent of the unsigned integer.
|
- **Unsigned integers**: Returns the signed integer equivalent of the unsigned integer.
|
||||||
- **Booleans**: Returns `1` for `true` and `0` for `false`.
|
- **Booleans**: Returns `1` for `true` and `0` for `false`.
|
||||||
- **Timestamps**: Returns the equivalent
|
- **Timestamps**: Returns the equivalent
|
||||||
[nanosecond epoch timestamp](/influxdb/cloud-iox/reference/glossary/#unix-timestamp).
|
[nanosecond epoch timestamp](/influxdb/cloud-dedicated/reference/glossary/#unix-timestamp).
|
||||||
|
|
||||||
### Cast to an unsigned integer
|
### Cast to an unsigned integer
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ SQL supports casting the following to an unsigned integer:
|
||||||
- **Integers**: Returns the unsigned integer equivalent of the signed integer.
|
- **Integers**: Returns the unsigned integer equivalent of the signed integer.
|
||||||
- **Booleans**: Returns `1` for `true` and `0` for `false`.
|
- **Booleans**: Returns `1` for `true` and `0` for `false`.
|
||||||
- **Timestamps**: Returns the equivalent
|
- **Timestamps**: Returns the equivalent
|
||||||
[nanosecond epoch timestamp](/influxdb/cloud-iox/reference/glossary/#unix-timestamp).
|
[nanosecond epoch timestamp](/influxdb/cloud-dedicated/reference/glossary/#unix-timestamp).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
---
|
||||||
|
title: Explore your schema with SQL
|
||||||
|
description: >
|
||||||
|
When working with InfluxDB's implementation of SQL, a **measurement** is
|
||||||
|
structured as a table, and **time**, **fields**, and **tags** are structured
|
||||||
|
as columns.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Explore your schema
|
||||||
|
parent: Query with SQL
|
||||||
|
identifier: query-sql-schema
|
||||||
|
weight: 201
|
||||||
|
influxdb/cloud-dedicated/tags: [query, sql]
|
||||||
|
list_code_example: |
|
||||||
|
##### List measurements
|
||||||
|
```sql
|
||||||
|
SHOW TABLES
|
||||||
|
```
|
||||||
|
|
||||||
|
##### List columns in a measurement
|
||||||
|
```sql
|
||||||
|
SHOW COLUMNS IN measurement
|
||||||
|
```
|
||||||
|
---
|
||||||
|
|
||||||
|
{{% sql/sql-schema-intro %}}
|
||||||
|
|
||||||
|
## List measurements in a database
|
||||||
|
|
||||||
|
Use `SHOW TABLES` to list measurements in your InfluxDB database.
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SHOW TABLES
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< expand-wrapper >}}
|
||||||
|
{{% expand "View example output" %}}
|
||||||
|
|
||||||
|
Tables listed with the `table_schema` of `iox` are measurements.
|
||||||
|
Tables with `system` or `information_schema` table schemas are system tables that
|
||||||
|
store internal metadata.
|
||||||
|
|
||||||
|
| table_catalog | table_schema | table_name | table_type |
|
||||||
|
| :------------ | :----------------- | :---------- | ---------: |
|
||||||
|
| public | iox | home | BASE TABLE |
|
||||||
|
| public | iox | noaa | BASE TABLE |
|
||||||
|
| public | system | queries | BASE TABLE |
|
||||||
|
| public | information_schema | tables | VIEW |
|
||||||
|
| public | information_schema | views | VIEW |
|
||||||
|
| public | information_schema | columns | VIEW |
|
||||||
|
| public | information_schema | df_settings | VIEW |
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
{{< /expand-wrapper >}}
|
||||||
|
|
||||||
|
## List columns in a measurement
|
||||||
|
|
||||||
|
Use the `SHOW COLUMNS` statement to view what columns are in a measurement.
|
||||||
|
Use the `IN` clause to specify the measurement.
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SHOW COLUMNS IN home
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< expand-wrapper >}}
|
||||||
|
{{% expand "View example output" %}}
|
||||||
|
|
||||||
|
| table_catalog | table_schema | table_name | column_name | data_type | is_nullable |
|
||||||
|
| :------------ | :----------- | :--------- | :---------- | :-------------------------- | ----------: |
|
||||||
|
| public | iox | home | co | Int64 | YES |
|
||||||
|
| public | iox | home | hum | Float64 | YES |
|
||||||
|
| public | iox | home | room | Dictionary(Int32, Utf8) | YES |
|
||||||
|
| public | iox | home | temp | Float64 | YES |
|
||||||
|
| public | iox | home | time | Timestamp(Nanosecond, None) | NO |
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
{{< /expand-wrapper >}}
|
|
@ -0,0 +1,16 @@
|
||||||
|
---
|
||||||
|
title: Use analysis and visualization tools with InfluxDB Cloud (IOx) APIs
|
||||||
|
description: >
|
||||||
|
Use popular tools to analyze and visualize time series data stored in an
|
||||||
|
InfluxDB database.
|
||||||
|
weight: 201
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Analyze and visualize data
|
||||||
|
parent: Query data
|
||||||
|
influxdb/cloud-dedicated/tags: [analysis, visualization, tools]
|
||||||
|
aliases:
|
||||||
|
- /influxdb/cloud-dedicated/visualize-data/
|
||||||
|
---
|
||||||
|
|
||||||
|
{{< children >}}
|
|
@ -0,0 +1,248 @@
|
||||||
|
---
|
||||||
|
title: Use Grafana to query and visualize data
|
||||||
|
seotitle: Use Grafana to query and visualize data stored in InfluxDB Cloud Dedicated
|
||||||
|
list_title: Use Grafana
|
||||||
|
description: >
|
||||||
|
Install and run [Grafana](https://grafana.com/) to query and visualize data stored in an
|
||||||
|
InfluxDB database.
|
||||||
|
weight: 101
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Use Grafana
|
||||||
|
parent: Analyze and visualize data
|
||||||
|
influxdb/cloud-dedicated/tags: [query, visualization]
|
||||||
|
aliases:
|
||||||
|
- /influxdb/cloud-dedicated/query-data/tools/grafana/
|
||||||
|
alt_engine: /influxdb/cloud/tools/grafana/
|
||||||
|
---
|
||||||
|
|
||||||
|
Use [Grafana](https://grafana.com/) to query and visualize data stored in an
|
||||||
|
InfluxDB Cloud dedicated database.
|
||||||
|
InfluxDB Cloud Dedicated supports both **SQL** and **InfluxQL** query languages.
|
||||||
|
Install the [Grafana FlightSQL plugin](https://grafana.com/grafana/plugins/influxdata-flightsql-datasource/)
|
||||||
|
to query InfluxDB with **SQL** using the Flight SQL protocol.
|
||||||
|
Use the **InfluxDB** core Grafana plugin to query data with **InfluxQL**.
|
||||||
|
|
||||||
|
> [Grafana] enables you to query, visualize, alert on, and explore your metrics,
|
||||||
|
> logs, and traces wherever they are stored.
|
||||||
|
> [Grafana] provides you with tools to turn your time-series database (TSDB)
|
||||||
|
> data into insightful graphs and visualizations.
|
||||||
|
>
|
||||||
|
> {{% caption %}}[Grafana documentation](https://grafana.com/docs/grafana/latest/introduction/){{% /caption %}}
|
||||||
|
|
||||||
|
<!-- TOC -->
|
||||||
|
|
||||||
|
- [Install Grafana or login to Grafana Cloud](#install-grafana-or-login-to-grafana-cloud)
|
||||||
|
- [Install the FlightSQL plugin](#install-the-flightsql-plugin)
|
||||||
|
- [Create a datasource](#create-a-datasource)
|
||||||
|
- [Query InfluxDB with Grafana](#query-influxdb-with-grafana)
|
||||||
|
- [Build visualizations with Grafana](#build-visualizations-with-grafana)
|
||||||
|
|
||||||
|
<!-- /TOC -->
|
||||||
|
|
||||||
|
## Install Grafana or login to Grafana Cloud
|
||||||
|
|
||||||
|
If using the open source version of **Grafana**, follow the
|
||||||
|
[Grafana installation instructions](https://grafana.com/docs/grafana/latest/setup-grafana/installation/)
|
||||||
|
to install Grafana for your operating system.
|
||||||
|
If using **Grafana Cloud**, login to your Grafana Cloud instance.
|
||||||
|
|
||||||
|
## Install the FlightSQL plugin
|
||||||
|
|
||||||
|
If you want to query InfluxDB Cloud Dedicated with **SQL**, install the
|
||||||
|
[Grafana FlightSQL plugin](https://grafana.com/grafana/plugins/influxdata-flightsql-datasource/).
|
||||||
|
|
||||||
|
{{< tabs-wrapper >}}
|
||||||
|
{{% tabs %}}
|
||||||
|
[Local Grafana](#)
|
||||||
|
[Grafana Cloud](#)
|
||||||
|
{{% /tabs %}}
|
||||||
|
{{% tab-content %}}
|
||||||
|
<!---------------------------- BEGIN LOCAL GRAFANA ---------------------------->
|
||||||
|
|
||||||
|
When using the local version of Grafana, you can install the FlightSQL plugin
|
||||||
|
with the [`grafana-cli` CLI](https://grafana.com/docs/grafana/latest/cli/) or in
|
||||||
|
the Grafana user interface (UI).
|
||||||
|
|
||||||
|
- [Use grafana-cli](#use-grafana-cli)
|
||||||
|
- [Use the Grafana UI](#use-the-grafana-ui)
|
||||||
|
|
||||||
|
### Use grafana-cli
|
||||||
|
|
||||||
|
Run the following command to install the FlightSQL plugin:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
grafana-cli plugins install influxdata-flightsql-datasource
|
||||||
|
```
|
||||||
|
|
||||||
|
After installing the plugin, you may need to restart your Grafana server.
|
||||||
|
|
||||||
|
### Use the Grafana UI
|
||||||
|
|
||||||
|
1. In the Grafana UI, navigate to **Configuration** > **Plugins**.
|
||||||
|
2. Search for and select the **FlightSQL** plugin.
|
||||||
|
3. Click **Install**.
|
||||||
|
|
||||||
|
<!----------------------------- END LOCAL GRAFANA ----------------------------->
|
||||||
|
{{% /tab-content %}}
|
||||||
|
{{% tab-content %}}
|
||||||
|
<!---------------------------- BEGIN GRAFANA CLOUD ---------------------------->
|
||||||
|
|
||||||
|
1. In your Grafana Cloud instance, navigate to **Administration** > **Plugins**.
|
||||||
|
2. Search for and select the **FlightSQL** plugin.
|
||||||
|
3. Click **Install via grafana.com** to navigate to the plugin page.
|
||||||
|
4. On the plugin page, click **Install plugin**.
|
||||||
|
|
||||||
|
After a moment, Grafana Cloud completes the plugin installation in your
|
||||||
|
Grafana Cloud instance.
|
||||||
|
|
||||||
|
<!----------------------------- END GRAFANA CLOUD ----------------------------->
|
||||||
|
{{% /tab-content %}}
|
||||||
|
{{< /tabs-wrapper >}}
|
||||||
|
|
||||||
|
## Create a datasource
|
||||||
|
|
||||||
|
Which datasource you create depends on which query language you want to use to
|
||||||
|
query InfluxDB Cloud Dedicated:
|
||||||
|
|
||||||
|
- To query with **SQL**, create a **FlightSQL** datasource.
|
||||||
|
- To query with **InfluxQL**, create an **InfluxDB** datasource.
|
||||||
|
|
||||||
|
{{< tabs-wrapper >}}
|
||||||
|
{{% tabs %}}
|
||||||
|
[SQL](#)
|
||||||
|
[InfluxQL](#)
|
||||||
|
{{% /tabs %}}
|
||||||
|
{{% tab-content %}}
|
||||||
|
<!--------------------------------- BEGIN SQL --------------------------------->
|
||||||
|
|
||||||
|
1. In your Grafana user interface (UI), navigate to **Data Sources**.
|
||||||
|
2. Click **Add new data source**.
|
||||||
|
3. Search for and select the **FlightSQL** plugin.
|
||||||
|
4. Provide a name for your datasource.
|
||||||
|
5. Add your connection credentials:
|
||||||
|
|
||||||
|
- **Host**: Provide the host and port of your Flight SQL client.
|
||||||
|
For InfluxDB Cloud Dedicated, this is your cluster URL and port 443:
|
||||||
|
|
||||||
|
```
|
||||||
|
cluster-id.influxdb.io:443
|
||||||
|
```
|
||||||
|
|
||||||
|
- **AuthType**: Select **token**.
|
||||||
|
- **Token**: Provide your InfluxDB API token with read access to the
|
||||||
|
databases you want to query.
|
||||||
|
- **Require TLS/SSL**: Enable this toggle.
|
||||||
|
|
||||||
|
6. Add connection **MetaData**.
|
||||||
|
Provide key-value pairs to send to your Flight SQL client.
|
||||||
|
|
||||||
|
InfluxDB Cloud Serverless requires your **database name**:
|
||||||
|
|
||||||
|
- **Key**: `iox-namespace-name`
|
||||||
|
- **Value**: Database name
|
||||||
|
|
||||||
|
7. Click **Save & test**.
|
||||||
|
|
||||||
|
{{< img-hd src="/img/influxdb/cloud-dedicated-grafana-flightsql-datasource.png" alt="Grafana FlightSQL datasource for InfluxDB Cloud Dedicated" />}}
|
||||||
|
|
||||||
|
If successful, click **Explore** to begin querying InfluxDB with Flight SQL and Grafana.
|
||||||
|
|
||||||
|
<!---------------------------------- END SQL ---------------------------------->
|
||||||
|
{{% /tab-content %}}
|
||||||
|
{{% tab-content %}}
|
||||||
|
<!------------------------------- BEGIN INFLUXQL ------------------------------>
|
||||||
|
|
||||||
|
1. In your Grafana user interface (UI), navigate to **Data Sources**.
|
||||||
|
2. Click **Add new data source**.
|
||||||
|
3. Search for and select the **InfluxDB** core plugin.
|
||||||
|
4. Provide a name for your datasource.
|
||||||
|
5. Under **Query Language**, select **InfluxQL**.
|
||||||
|
_InfluxDB Cloud Dedicated does not support Flux._
|
||||||
|
6. Under **HTTP**:
|
||||||
|
|
||||||
|
- **URL**: Provide your Influx Cloud Dedicated cluster URL using the HTTPS
|
||||||
|
protocol:
|
||||||
|
|
||||||
|
```
|
||||||
|
https://cluster-id.influxdb.io
|
||||||
|
```
|
||||||
|
|
||||||
|
7. Under **InfluxDB Details**:
|
||||||
|
|
||||||
|
- **Database**: Provide a default database name to query.
|
||||||
|
- **User**: Provide an arbitrary string.
|
||||||
|
_This credential is ingored when querying InfluxDB Cloud Dedicated, but it cannot be empty._
|
||||||
|
- **Password**: Provide an InfluxDB [database token](/influxdb/cloud-dedicated/admin/tokens/)
|
||||||
|
with read access to the databases you want to query.
|
||||||
|
|
||||||
|
7. Click **Save & test**.
|
||||||
|
|
||||||
|
{{< img-hd src="/img/influxdb/cloud-dedicated-grafana-influxdb-datasource.png" alt="Grafana InfluxDB datasource for InfluxDB Cloud Dedicated" />}}
|
||||||
|
|
||||||
|
|
||||||
|
<!-------------------------------- END INFLUXQL ------------------------------->
|
||||||
|
{{% /tab-content %}}
|
||||||
|
{{< /tabs-wrapper >}}
|
||||||
|
|
||||||
|
## Query InfluxDB with Grafana
|
||||||
|
|
||||||
|
After you [configure and save a FlightSQL or InfluxDB datasource](#create-a-datasource),
|
||||||
|
use Grafana to build, run, and inspect queries against InfluxDB database.
|
||||||
|
|
||||||
|
{{< tabs-wrapper >}}
|
||||||
|
{{% tabs %}}
|
||||||
|
[SQL](#)
|
||||||
|
[InfluxQL](#)
|
||||||
|
{{% /tabs %}}
|
||||||
|
{{% tab-content %}}
|
||||||
|
<!--------------------------------- BEGIN SQL --------------------------------->
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
{{% sql/sql-schema-intro %}}
|
||||||
|
To learn more, see [Query Data](/influxdb/cloud-dedicated/query-data/sql/).
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
|
1. Click **Explore**.
|
||||||
|
2. In the dropdown, select the **FlightSQL** data source that you want to query.
|
||||||
|
3. Use the SQL query form to build your query:
|
||||||
|
- **FROM**: Select the measurement that you want to query.
|
||||||
|
- **SELECT**: Select one or more fields and tags to return as columns in query results.
|
||||||
|
In Grafana, you must specify a **time** column in the `SELECT` list.
|
||||||
|
- **WHERE**: To filter the query results, enter a conditional expression.
|
||||||
|
- **GROUP BY**: To `GROUP BY` one or more fields or tags, enter them as a comma-delimited list.
|
||||||
|
If you include an aggregate function in the **SELECT** list,
|
||||||
|
then you must include one or more of the queried columns in
|
||||||
|
a `GROUP BY` or `PARTITION BY` clause.
|
||||||
|
SQL will return the aggregation for each group or partition.
|
||||||
|
4. Click **Run query** to execute the query.
|
||||||
|
|
||||||
|
<!---------------------------------- END SQL ---------------------------------->
|
||||||
|
{{% /tab-content %}}
|
||||||
|
{{% tab-content %}}
|
||||||
|
<!------------------------------- BEGIN INFLUXQL ------------------------------>
|
||||||
|
|
||||||
|
1. Click **Explore**.
|
||||||
|
2. In the dropdown, select the **InfluxDB** data source that you want to query.
|
||||||
|
3. Use the InfluxQL query form to build your query:
|
||||||
|
- **FROM**: Select the measurement that you want to query.
|
||||||
|
- **WHERE**: To filter the query results, enter a conditional expression.
|
||||||
|
- **SELECT**: Select fields to query and an aggregate function to apply to each.
|
||||||
|
The aggregate function is applied to each time interval defined in the
|
||||||
|
`GROUP BY` clause.
|
||||||
|
- **GROUP BY**: By default, Grafana groups data by time to downsample results
|
||||||
|
and improve query performance.
|
||||||
|
You can also add other tags to group by.
|
||||||
|
4. Click **Run query** to execute the query.
|
||||||
|
|
||||||
|
<!-------------------------------- END INFLUXQL ------------------------------->
|
||||||
|
{{% /tab-content %}}
|
||||||
|
{{< /tabs-wrapper >}}
|
||||||
|
|
||||||
|
To learn about query management and inspection in Grafana, see the
|
||||||
|
[Grafana Explore documentation](https://grafana.com/docs/grafana/latest/explore/).
|
||||||
|
|
||||||
|
## Build visualizations with Grafana
|
||||||
|
|
||||||
|
For a comprehensive walk-through of creating visualizations with
|
||||||
|
Grafana, see the [Grafana documentation](https://grafana.com/docs/grafana/latest/).
|
|
@ -0,0 +1,200 @@
|
||||||
|
---
|
||||||
|
title: Use pandas to analyze and visualize data
|
||||||
|
seotitle: Use Python and pandas to analyze and visualize data
|
||||||
|
description: >
|
||||||
|
Use the [pandas](https://pandas.pydata.org/) Python data analysis library
|
||||||
|
to analyze and visualize data stored in InfluxDB.
|
||||||
|
weight: 101
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: Analyze and visualize data
|
||||||
|
name: Use pandas
|
||||||
|
influxdb/cloud-dedicated/tags: [analysis, pandas, pyarrow, python, visualization]
|
||||||
|
related:
|
||||||
|
- /influxdb/cloud-dedicated/query-data/tools/python/
|
||||||
|
- /influxdb/cloud-dedicated/query-data/tools/pyarrow/
|
||||||
|
- /influxdb/cloud-dedicated/query-data/sql/
|
||||||
|
list_code_example: |
|
||||||
|
```py
|
||||||
|
...
|
||||||
|
dataframe = reader.read_pandas()
|
||||||
|
dataframe = dataframe.set_index('time')
|
||||||
|
|
||||||
|
print(dataframe.index)
|
||||||
|
|
||||||
|
resample = dataframe.resample("1H")
|
||||||
|
|
||||||
|
resample['temp'].mean()
|
||||||
|
```
|
||||||
|
---
|
||||||
|
|
||||||
|
Use [pandas](https://pandas.pydata.org/), the Python data analysis library, to process, analyze, and visualize data
|
||||||
|
stored in InfluxDB.
|
||||||
|
|
||||||
|
> **pandas** is an open source, BSD-licensed library providing high-performance,
|
||||||
|
> easy-to-use data structures and data analysis tools for the Python programming language.
|
||||||
|
>
|
||||||
|
> {{% caption %}}[pandas documentation](https://pandas.pydata.org/docs/){{% /caption %}}
|
||||||
|
|
||||||
|
<!-- TOC -->
|
||||||
|
|
||||||
|
- [Install prerequisites](#install-prerequisites)
|
||||||
|
- [Install pandas](#install-pandas)
|
||||||
|
- [Use PyArrow to convert query results to pandas](#use-pyarrow-to-convert-query-results-to-pandas)
|
||||||
|
- [Use pandas to analyze data](#use-pandas-to-analyze-data)
|
||||||
|
- [View data information and statistics](#view-data-information-and-statistics)
|
||||||
|
- [Downsample time series](#downsample-time-series)
|
||||||
|
|
||||||
|
<!-- /TOC -->
|
||||||
|
|
||||||
|
## Install prerequisites
|
||||||
|
|
||||||
|
The examples in this guide assume using a Python virtual environment and the Flight SQL library for Python.
|
||||||
|
Installing `flightsql-dbapi` also installs the [`pyarrow`](https://arrow.apache.org/docs/python/index.html) library that provides Python bindings for Apache Arrow.
|
||||||
|
|
||||||
|
For more information, see how to [get started querying InfluxDB with Python and flightsql-dbapi](/influxdb/cloud-dedicated/query-data/execute-queries/flight-sql/python/)
|
||||||
|
|
||||||
|
## Install pandas
|
||||||
|
|
||||||
|
To use pandas, you need to install and import the `pandas` library.
|
||||||
|
|
||||||
|
In your terminal, use `pip` to install `pandas` in your active [Python virtual environment](/influxdb/cloud-dedicated/query-data/execute-queries/flight-sql/python/#venv-install):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pip install pandas
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use PyArrow to convert query results to pandas
|
||||||
|
|
||||||
|
The following steps use Python, `flightsql-dbapi`, and `pyarrow` to query InfluxDB and stream Arrow data to a pandas `DataFrame`.
|
||||||
|
|
||||||
|
1. In your editor, copy and paste the following code to a new file--for example, `pandas-example.py`:
|
||||||
|
|
||||||
|
```py
|
||||||
|
# pandas-example.py
|
||||||
|
|
||||||
|
from flightsql import FlightSQLClient
|
||||||
|
import pandas
|
||||||
|
|
||||||
|
client = FlightSQLClient(host='cluster-id.influxdb.io',
|
||||||
|
token='INFLUX_READ_WRITE_TOKEN',
|
||||||
|
metadata={'iox-namespace-name': 'INFLUX_DATABASE'},
|
||||||
|
features={'metadata-reflection': 'true'})
|
||||||
|
|
||||||
|
info = client.execute("SELECT * FROM home")
|
||||||
|
|
||||||
|
reader = client.do_get(info.endpoints[0].ticket)
|
||||||
|
|
||||||
|
# Read all record batches in the stream to a pandas DataFrame
|
||||||
|
dataframe = reader.read_pandas()
|
||||||
|
|
||||||
|
dataframe.info()
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Replace the following configuration values:
|
||||||
|
|
||||||
|
- **`INFLUX_READ_WRITE_TOKEN`**: Your InfluxDB token with read permissions on the databases you want to query.
|
||||||
|
- **`INFLUX_DATABASE`**: The name of your InfluxDB database.
|
||||||
|
|
||||||
|
3. In your terminal, use the Python interpreter to run the file:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python pandas-example.py
|
||||||
|
```
|
||||||
|
|
||||||
|
The `pyarrow.flight.FlightStreamReader` [`read_pandas()`](https://arrow.apache.org/docs/python/generated/pyarrow.flight.FlightStreamReader.html#pyarrow.flight.FlightStreamReader.read_pandas) method:
|
||||||
|
|
||||||
|
- Takes the same options as [`pyarrow.Table.to_pandas()`](https://arrow.apache.org/docs/python/generated/pyarrow.Table.html#pyarrow.Table.to_pandas).
|
||||||
|
- Reads all Arrow record batches in the stream to a `pyarrow.Table` and then converts the `Table` to a [`pandas.DataFrame`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html#pandas.DataFrame).
|
||||||
|
|
||||||
|
Next, [use pandas to analyze data](#use-pandas-to-analyze-data).
|
||||||
|
|
||||||
|
## Use pandas to analyze data
|
||||||
|
|
||||||
|
- [View data information and statistics](#view-data-information-and-statistics)
|
||||||
|
- [Downsample time series](#downsample-time-series)
|
||||||
|
|
||||||
|
### View data information and statistics
|
||||||
|
|
||||||
|
The following example uses the DataFrame `info()` and `describe()`
|
||||||
|
methods to print information about the DataFrame.
|
||||||
|
|
||||||
|
```py
|
||||||
|
# pandas-example.py
|
||||||
|
|
||||||
|
from flightsql import FlightSQLClient
|
||||||
|
import pandas
|
||||||
|
|
||||||
|
client = FlightSQLClient(host='cluster-id.influxdb.io',
|
||||||
|
token='INFLUX_READ_WRITE_TOKEN',
|
||||||
|
metadata={'iox-namespace-name': 'INFLUX_DATABASE'},
|
||||||
|
features={'metadata-reflection': 'true'})
|
||||||
|
|
||||||
|
info = client.execute("SELECT * FROM home")
|
||||||
|
|
||||||
|
reader = client.do_get(info.endpoints[0].ticket)
|
||||||
|
|
||||||
|
dataframe = reader.read_pandas()
|
||||||
|
|
||||||
|
# Print a summary of the DataFrame to stdout
|
||||||
|
dataframe.info()
|
||||||
|
|
||||||
|
# Calculate summary statistics for the data
|
||||||
|
print(dataframe.describe())
|
||||||
|
```
|
||||||
|
|
||||||
|
### Downsample time series
|
||||||
|
|
||||||
|
The pandas library provides extensive features for working with time series data.
|
||||||
|
|
||||||
|
The [`pandas.DataFrame.resample()` method](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.resample.html) downsamples and upsamples data to time-based groups--for example:
|
||||||
|
|
||||||
|
```py
|
||||||
|
from flightsql import FlightSQLClient
|
||||||
|
import pandas
|
||||||
|
|
||||||
|
client = FlightSQLClient(host='cluster-id.influxdb.io',
|
||||||
|
token='INFLUX_READ_WRITE_TOKEN',
|
||||||
|
metadata={'iox-namespace-name': 'INFLUX_DATABASE'},
|
||||||
|
features={'metadata-reflection': 'true'})
|
||||||
|
|
||||||
|
info = client.execute("SELECT * FROM home")
|
||||||
|
|
||||||
|
reader = client.do_get(info.endpoints[0].ticket)
|
||||||
|
|
||||||
|
dataframe = reader.read_pandas()
|
||||||
|
|
||||||
|
# Use the `time` column to generate a DatetimeIndex for the DataFrame
|
||||||
|
dataframe = dataframe.set_index('time')
|
||||||
|
|
||||||
|
# Print information about the index
|
||||||
|
print(dataframe.index)
|
||||||
|
|
||||||
|
# Downsample data into 1-hour groups based on the DatetimeIndex
|
||||||
|
resample = dataframe.resample("1H")
|
||||||
|
|
||||||
|
# Print a summary that shows the start time and average temp for each group
|
||||||
|
print(resample['temp'].mean())
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< expand-wrapper >}}
|
||||||
|
{{% expand "View example results" %}}
|
||||||
|
```sh
|
||||||
|
time
|
||||||
|
1970-01-01 00:00:00 22.374138
|
||||||
|
1970-01-01 01:00:00 NaN
|
||||||
|
1970-01-01 02:00:00 NaN
|
||||||
|
1970-01-01 03:00:00 NaN
|
||||||
|
1970-01-01 04:00:00 NaN
|
||||||
|
...
|
||||||
|
2023-07-16 22:00:00 NaN
|
||||||
|
2023-07-16 23:00:00 22.600000
|
||||||
|
2023-07-17 00:00:00 22.513889
|
||||||
|
2023-07-17 01:00:00 22.208333
|
||||||
|
2023-07-17 02:00:00 22.300000
|
||||||
|
Freq: H, Name: temp, Length: 469323, dtype: float64
|
||||||
|
```
|
||||||
|
{{% /expand %}}
|
||||||
|
{{< /expand-wrapper >}}
|
||||||
|
|
||||||
|
For more detail and examples, see the [pandas documentation](https://pandas.pydata.org/docs/index.html).
|
|
@ -0,0 +1,136 @@
|
||||||
|
---
|
||||||
|
title: Use the PyArrow library to analyze data
|
||||||
|
description: >
|
||||||
|
Use [PyArrow](https://arrow.apache.org/docs/python/) to read and analyze InfluxDB query results.
|
||||||
|
weight: 101
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: Analyze and visualize data
|
||||||
|
name: Use PyArrow
|
||||||
|
influxdb/cloud-dedicated/tags: [analysis, arrow, pyarrow, python]
|
||||||
|
related:
|
||||||
|
- /influxdb/cloud-dedicated/query-data/tools/pandas/
|
||||||
|
- /influxdb/cloud-dedicated/query-data/tools/pyarrow/
|
||||||
|
- /influxdb/cloud-dedicated/query-data/sql/
|
||||||
|
list_code_example: |
|
||||||
|
```py
|
||||||
|
...
|
||||||
|
table = reader.read_all()
|
||||||
|
table.group_by('room').aggregate([('temp', 'mean')])
|
||||||
|
```
|
||||||
|
---
|
||||||
|
|
||||||
|
Use [PyArrow](https://arrow.apache.org/docs/python/) to read and analyze query results
|
||||||
|
from InfluxDB Cloud Dedicated
|
||||||
|
The PyArrow library provides efficient computation, aggregation, serialization, and conversion of Arrow format data.
|
||||||
|
|
||||||
|
> Apache Arrow is a development platform for in-memory analytics. It contains a set of technologies that enable
|
||||||
|
> big data systems to store, process and move data fast.
|
||||||
|
>
|
||||||
|
> The Arrow Python bindings (also named “PyArrow”) have first-class integration with NumPy, pandas, and built-in Python objects. They are based on the C++ implementation of Arrow.
|
||||||
|
> {{% caption %}}[PyArrow documentation](https://arrow.apache.org/docs/python/index.html){{% /caption %}}
|
||||||
|
|
||||||
|
<!-- TOC -->
|
||||||
|
|
||||||
|
- [Install prerequisites](#install-prerequisites)
|
||||||
|
- [Use PyArrow to read query results](#use-pyarrow-to-read-query-results)
|
||||||
|
- [Use PyArrow to analyze data](#use-pyarrow-to-analyze-data)
|
||||||
|
- [Group and aggregate data](#group-and-aggregate-data)
|
||||||
|
|
||||||
|
<!-- /TOC -->
|
||||||
|
|
||||||
|
## Install prerequisites
|
||||||
|
|
||||||
|
The examples in this guide assume using a Python virtual environment and the Flight SQL library for Python.
|
||||||
|
For more information, see how to [get started using Python to query InfluxDB](/influxdb/cloud-dedicated/query-data/execute-queries/flight-sql/python/)
|
||||||
|
|
||||||
|
Installing `flightsql-dbapi` also installs the [`pyarrow`](https://arrow.apache.org/docs/python/index.html) library that provides Python bindings for Apache Arrow.
|
||||||
|
|
||||||
|
## Use PyArrow to read query results
|
||||||
|
|
||||||
|
The following example shows how to use Python with `flightsql-dbapi` and `pyarrow` to query InfluxDB and view Arrow data as a PyArrow `Table`.
|
||||||
|
|
||||||
|
1. In your editor, copy and paste the following sample code to a new file--for example, `pyarrow-example.py`:
|
||||||
|
|
||||||
|
```py
|
||||||
|
# pyarrow-example.py
|
||||||
|
|
||||||
|
from flightsql import FlightSQLClient
|
||||||
|
|
||||||
|
# Instantiate a FlightSQLClient configured for a database
|
||||||
|
client = FlightSQLClient(host='cluster-id.influxdb.io',
|
||||||
|
token='INFLUX_READ_WRITE_TOKEN',
|
||||||
|
metadata={'iox-namespace-name': 'INFLUX_DATABASE'},
|
||||||
|
features={'metadata-reflection': 'true'})
|
||||||
|
|
||||||
|
# Execute the query to retrieve FlightInfo
|
||||||
|
info = client.execute('SELECT * FROM home')
|
||||||
|
|
||||||
|
# Use the ticket to request the Arrow data stream.
|
||||||
|
# Return a FlightStreamReader for streaming the results.
|
||||||
|
reader = client.do_get(info.endpoints[0].ticket)
|
||||||
|
|
||||||
|
# Read all data to a pyarrow.Table
|
||||||
|
table = reader.read_all()
|
||||||
|
|
||||||
|
print(table)
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Replace the following configuration values:
|
||||||
|
|
||||||
|
- **`INFLUX_READ_WRITE_TOKEN`**: Your InfluxDB token with read permissions on the databases you want to query.
|
||||||
|
- **`INFLUX_DATABASE`**: The name of your InfluxDB database.
|
||||||
|
|
||||||
|
|
||||||
|
3. In your terminal, use the Python interpreter to run the file:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python pyarrow-example.py
|
||||||
|
```
|
||||||
|
|
||||||
|
The `FlightStreamReader.read_all()` method reads all Arrow record batches in the stream as a [`pyarrow.Table`](https://arrow.apache.org/docs/python/generated/pyarrow.Table.html).
|
||||||
|
|
||||||
|
Next, [use PyArrow to analyze data](#use-pyarrow-to-analyze-data).
|
||||||
|
|
||||||
|
## Use PyArrow to analyze data
|
||||||
|
|
||||||
|
### Group and aggregate data
|
||||||
|
|
||||||
|
With a `pyarrow.Table`, you can use values in a column as _keys_ for grouping.
|
||||||
|
|
||||||
|
The following example shows how to query InfluxDB, group the table data, and then calculate an aggregate value for each group:
|
||||||
|
|
||||||
|
```py
|
||||||
|
# pyarrow-example.py
|
||||||
|
|
||||||
|
from flightsql import FlightSQLClient
|
||||||
|
|
||||||
|
client = FlightSQLClient(host='cluster-id.influxdb.io',
|
||||||
|
token='INFLUX_READ_WRITE_TOKEN',
|
||||||
|
metadata={'iox-namespace-name': 'INFLUX_DATABASE'},
|
||||||
|
features={'metadata-reflection': 'true'})
|
||||||
|
|
||||||
|
info = client.execute('SELECT * FROM home')
|
||||||
|
|
||||||
|
reader = client.do_get(info.endpoints[0].ticket)
|
||||||
|
|
||||||
|
table = reader.read_all()
|
||||||
|
|
||||||
|
# Use PyArrow to aggregate data
|
||||||
|
print(table.group_by('room').aggregate([('temp', 'mean')]))
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< expand-wrapper >}}
|
||||||
|
{{% expand "View example results" %}}
|
||||||
|
```arrow
|
||||||
|
pyarrow.Table
|
||||||
|
temp_mean: double
|
||||||
|
room: string
|
||||||
|
----
|
||||||
|
temp_mean: [[22.581987577639747,22.10807453416151]]
|
||||||
|
room: [["Kitchen","Living Room"]]
|
||||||
|
```
|
||||||
|
{{% /expand %}}
|
||||||
|
{{< /expand-wrapper >}}
|
||||||
|
|
||||||
|
For more detail and examples, see the [PyArrow documentation](https://arrow.apache.org/docs/python/getstarted.html) and the [Apache Arrow Python Cookbook](https://arrow.apache.org/cookbook/py/data.html).
|
|
@ -0,0 +1,38 @@
|
||||||
|
---
|
||||||
|
title: Use Superset to visualize data
|
||||||
|
seotitle: Use Apache Superset to visualize data stored in InfluxDB
|
||||||
|
list_title: Superset
|
||||||
|
description: >
|
||||||
|
Use [Apache Superset](https://superset.apache.org/) to query and visualize data
|
||||||
|
stored in an InfluxDB database.
|
||||||
|
weight: 101
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: Analyze and visualize data
|
||||||
|
name: Use Superset
|
||||||
|
identifier: visualize_with_superset
|
||||||
|
influxdb/cloud-dedicated/tags: [query, visualization]
|
||||||
|
aliases:
|
||||||
|
- /influxdb/cloud-dedicated/visualize-data/superset/
|
||||||
|
related:
|
||||||
|
- /influxdb/cloud-dedicated/query-data/execute-queries/flight-sql/superset/
|
||||||
|
---
|
||||||
|
|
||||||
|
Use [Apache Superset](https://superset.apache.org/) to query and visualize data
|
||||||
|
stored in an InfluxDB database.
|
||||||
|
|
||||||
|
> Apache Superset is a modern, enterprise-ready business intelligence web application.
|
||||||
|
> It is fast, lightweight, intuitive, and loaded with options that make it easy for
|
||||||
|
> users of all skill sets to explore and visualize their data, from simple pie
|
||||||
|
> charts to highly detailed deck.gl geospatial charts.
|
||||||
|
>
|
||||||
|
> {{% cite %}}-- [Apache Superset documentation](https://superset.apache.org/docs/intro){{% /cite %}}
|
||||||
|
|
||||||
|
To get started with Superset and InfluxDB, see [Use Superset to query data](/influxdb/cloud-dedicated/query-data/execute-queries/flight-sql/superset/).
|
||||||
|
## Build visualizations with Superset
|
||||||
|
|
||||||
|
Use Superset to create visualizations and dashboards for InfluxDB IOx queries.
|
||||||
|
For a comprehensive walk-through of creating visualizations with
|
||||||
|
Superset, see the [Creating Charts and Dashboards in Superset documentation](https://superset.apache.org/docs/creating-charts-dashboards/creating-your-first-dashboard).
|
||||||
|
|
||||||
|
{{< img-hd src="/img/influxdb/cloud-serverless-superset-dashboard.png" alt="Build InfluxDB dashboards in Apache Superset" />}}
|
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
title: InfluxDB Cloud Dedicated reference documentation
|
||||||
|
description: >
|
||||||
|
Reference documentation for InfluxDB Cloud Dedicated including updates,
|
||||||
|
API documentation, tools, syntaxes, and more.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Reference
|
||||||
|
weight: 20
|
||||||
|
---
|
||||||
|
|
||||||
|
{{< children >}}
|
|
@ -0,0 +1,19 @@
|
||||||
|
---
|
||||||
|
title: Command line tools
|
||||||
|
seotitle: Command line tools for managing InfluxDB Cloud Dedicated
|
||||||
|
description: >
|
||||||
|
InfluxDB provides command line tools designed to manage and work with your
|
||||||
|
InfluxDB Cloud Dedicated cluster from the command line.
|
||||||
|
influxdb/cloud-dedicated/tags: [cli]
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: Reference
|
||||||
|
name: CLIs
|
||||||
|
weight: 104
|
||||||
|
---
|
||||||
|
|
||||||
|
InfluxDB provides command line tools designed to manage and work with your
|
||||||
|
InfluxDB Cloud Dedicated cluster from the command line.
|
||||||
|
The following command line interfaces (CLIs) are available:
|
||||||
|
|
||||||
|
{{< children >}}
|
|
@ -0,0 +1,92 @@
|
||||||
|
---
|
||||||
|
title: influxctl
|
||||||
|
list_title: influxctl
|
||||||
|
description: >
|
||||||
|
The `influxctl` command line interface (CLI) performs administrative tasks in
|
||||||
|
an InfluxDB Cloud Dedicated cluster.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: influxctl
|
||||||
|
parent: CLIs
|
||||||
|
weight: 101
|
||||||
|
influxdb/cloud-dedicated/tags: [cli]
|
||||||
|
---
|
||||||
|
|
||||||
|
The `influxctl` command line interface (CLI) performs administrative tasks in
|
||||||
|
an InfluxDB Cloud Dedicated cluster.
|
||||||
|
|
||||||
|
- [Usage](#usage)
|
||||||
|
- [Commands](#commands)
|
||||||
|
- [Flags](#command-flags)
|
||||||
|
- [Download and install influxctl](#download-and-install-influxctl)
|
||||||
|
- [Configure connection profiles](#configure-connection-profiles)
|
||||||
|
- [Authentication](#authentication)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl [flags] [command]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
| Command | Description |
|
||||||
|
| :---------------------------------------------------------------------- | :------------------------------------- |
|
||||||
|
| [database](/influxdb/cloud-dedicated/reference/cli/influxctl/database/) | Manage InfluxDB databases |
|
||||||
|
| [token](/influxdb/cloud-dedicated/reference/cli/influxctl/token/) | Manage InfluxDB database tokens |
|
||||||
|
| [version](/influxdb/cloud-dedicated/reference/cli/influxctl/version/) | Output the current `influxctl` version |
|
||||||
|
| [help](/influxdb/cloud-dedicated/reference/cli/influxctl/help/) | Output `influxctl` help information |
|
||||||
|
|
||||||
|
## Global flags
|
||||||
|
|
||||||
|
| Flag | Description |
|
||||||
|
| :---------- | :--------------------------------------------------------- |
|
||||||
|
| `--debug` | Enable debug logging |
|
||||||
|
| `--profile` | Specify a connection profile to use (default is `default`) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Download and install influxctl
|
||||||
|
|
||||||
|
_Contact your InfluxData account representative for information about
|
||||||
|
downloading and installing the `influxctl` CLI._
|
||||||
|
|
||||||
|
## Configure connection profiles
|
||||||
|
|
||||||
|
To connect with your InfluxDB Cloud Dedicated cluster, `influxctl` needs the
|
||||||
|
following credentials:
|
||||||
|
|
||||||
|
- InfluxDB Cloud Dedicated account ID
|
||||||
|
- InfluxDB Cloud Dedicated cluster ID
|
||||||
|
|
||||||
|
Use the [`influxctl init` command](/influxdb/cloud-dedicated/reference/cli/influxctl/init)
|
||||||
|
to start an interactive prompt that creates and stores the required credentials
|
||||||
|
as a **connection profile**.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl init
|
||||||
|
```
|
||||||
|
|
||||||
|
### Connection profile store location
|
||||||
|
|
||||||
|
The `influxctl` CLI stores connection profiles in a `config.toml` file at a specific
|
||||||
|
location based on your operating system:
|
||||||
|
|
||||||
|
#### Profile configuration file locations
|
||||||
|
|
||||||
|
| Operating system | Profile configuration filepath |
|
||||||
|
| :--------------- | :---------------------------------------------------- |
|
||||||
|
| Linux | `~/.config/influxctl/config.toml` |
|
||||||
|
| macOS | `~/Library/Application Support/influxctl/config.toml` |
|
||||||
|
| Windows | `%APPDATA%\influxctl\config.toml` |
|
||||||
|
|
||||||
|
## Authentication
|
||||||
|
|
||||||
|
The `influxctl` CLI uses [Auth0](https://auth0.com/) to authenticate access to
|
||||||
|
your InfluxDB Cloud Dedicated cluster.
|
||||||
|
When you issue an `influxctl` command, the CLI checks for an active **Auth0** token.
|
||||||
|
If none exists, you are directed to login to **Auth0** via a browser using
|
||||||
|
credentials you should have created when setting up your InfluxDB Cloud
|
||||||
|
Dedicated cluster.
|
||||||
|
Auth0 issues a short-lived (1 hour) token that authenticates access to your
|
||||||
|
InfluxDB Cloud Dedicated cluster.
|
|
@ -0,0 +1,33 @@
|
||||||
|
---
|
||||||
|
title: influxctl database
|
||||||
|
description: >
|
||||||
|
The `influx database` command and its subcommands manage databases in an
|
||||||
|
InfluxDB Cloud Dedicated cluster.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: influxctl
|
||||||
|
weight: 201
|
||||||
|
---
|
||||||
|
|
||||||
|
The `influx database` command and its subcommands manage databases in an
|
||||||
|
InfluxDB Cloud Dedicated cluster.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl database [subcommand] [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Subcommands
|
||||||
|
|
||||||
|
| Subcommand | Description |
|
||||||
|
| :--------------------------------------------------------------------------- | :---------------- |
|
||||||
|
| [create](/influxdb/cloud-dedicated/reference/cli/influxctl/database/create/) | Create a database |
|
||||||
|
| [list](/influxdb/cloud-dedicated/reference/cli/influxctl/database/list/) | List databases |
|
||||||
|
| [delete](/influxdb/cloud-dedicated/reference/cli/influxctl/database/delete/) | Delete a database |
|
||||||
|
|
||||||
|
## Flags
|
||||||
|
|
||||||
|
| Flag | | Description |
|
||||||
|
| :--- | :------- | :------------------ |
|
||||||
|
| `-h` | `--help` | Output command help |
|
|
@ -0,0 +1,86 @@
|
||||||
|
---
|
||||||
|
title: influxctl database create
|
||||||
|
description: >
|
||||||
|
The `influxctl database create` command creates a new database in an InfluxDB
|
||||||
|
Cloud Dedicated cluster.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: influxctl database
|
||||||
|
weight: 301
|
||||||
|
---
|
||||||
|
|
||||||
|
The `influxctl database create` command creates a new database with a specified
|
||||||
|
retention period in an InfluxDB Cloud Dedicated cluster.
|
||||||
|
|
||||||
|
The retention period defines the maximum age of data retained in the database,
|
||||||
|
based on the timestamp of the data.
|
||||||
|
The retention period value is a time duration value made up of a numeric value
|
||||||
|
plus a duration unit. For example, `30d` means 30 days.
|
||||||
|
A zero duration retention period is infinite and data will not expire.
|
||||||
|
The retention period value cannot be negative or contain whitespace.
|
||||||
|
|
||||||
|
{{< flex >}}
|
||||||
|
{{% flex-content %}}
|
||||||
|
|
||||||
|
##### Valid durations units include
|
||||||
|
|
||||||
|
- **m**: minute
|
||||||
|
- **h**: hour
|
||||||
|
- **d**: day
|
||||||
|
- **w**: week
|
||||||
|
- **mo**: month
|
||||||
|
- **y**: year
|
||||||
|
|
||||||
|
{{% /flex-content %}}
|
||||||
|
{{% flex-content %}}
|
||||||
|
|
||||||
|
##### Example retention period values
|
||||||
|
|
||||||
|
- `0d`: infinite/none
|
||||||
|
- `3d`: 3 days
|
||||||
|
- `6w`: 6 weeks
|
||||||
|
- `1mo`: 1 month (30 days)
|
||||||
|
- `1y`: 1 year
|
||||||
|
- `30d30d`: 60 days
|
||||||
|
- `2.5d`: 60 hours
|
||||||
|
|
||||||
|
{{% /flex-content %}}
|
||||||
|
{{< /flex >}}
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl database create [--retention-period 0s] <DATABASE_NAME>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Arguments
|
||||||
|
|
||||||
|
| Argument | Description |
|
||||||
|
| :---------------- | :--------------------- |
|
||||||
|
| **DATABASE_NAME** | InfluxDB database name |
|
||||||
|
|
||||||
|
## Flags
|
||||||
|
|
||||||
|
| Flag | | Description |
|
||||||
|
| :--- | :------------------- | :---------------------------------------------------- |
|
||||||
|
| `-h` | `--help` | Output command help |
|
||||||
|
| | `--retention-period` | Database retention period (default is 0s or infinite) |
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
- [Create a database with an infinite retention period](#create-a-database-with-an-infinite-retention-period)
|
||||||
|
- [Create a database with a 30 day retention period](#create-a-database-with-a-30-day-retention-period)
|
||||||
|
|
||||||
|
##### Create a database with an infinite retention period
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl database create mydb
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Create a database with a 30 day retention period
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl database create \
|
||||||
|
--retention-period 30d \
|
||||||
|
mydb
|
||||||
|
```
|
|
@ -0,0 +1,50 @@
|
||||||
|
---
|
||||||
|
title: influxctl database delete
|
||||||
|
description: >
|
||||||
|
The `influxctl database delete` command deletes a database from an InfluxDB
|
||||||
|
Cloud Dedicated cluster.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: influxctl database
|
||||||
|
weight: 302
|
||||||
|
---
|
||||||
|
|
||||||
|
The `influxctl database delete` command deletes a database from an InfluxDB
|
||||||
|
Cloud Dedicated cluster.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl database delete <DATABASE_NAME>
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% warn %}}
|
||||||
|
#### Cannot be undone
|
||||||
|
|
||||||
|
Deleting a database is a destructive action that cannot be undone.
|
||||||
|
|
||||||
|
#### Cannot reuse deleted database names
|
||||||
|
|
||||||
|
After deleting a database, you cannot reuse the name of the deleted database
|
||||||
|
when creating a new database.
|
||||||
|
{{% /warn %}}
|
||||||
|
|
||||||
|
## Arguments
|
||||||
|
|
||||||
|
| Argument | Description |
|
||||||
|
| :---------------- | :----------------------------- |
|
||||||
|
| **DATABASE_NAME** | Name of the database to delete |
|
||||||
|
|
||||||
|
## Flags
|
||||||
|
|
||||||
|
| Flag | | Description |
|
||||||
|
| :--- | :------- | :------------------ |
|
||||||
|
| `-h` | `--help` | Output command help |
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
##### Delete a database named "mydb"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl database delete mydb
|
||||||
|
```
|
|
@ -0,0 +1,26 @@
|
||||||
|
---
|
||||||
|
title: influxctl database list
|
||||||
|
description: >
|
||||||
|
The `influxctl database list` command lists all databases in an InfluxDB Cloud
|
||||||
|
Dedicated cluster.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: influxctl database
|
||||||
|
weight: 301
|
||||||
|
---
|
||||||
|
|
||||||
|
The `influxctl database list` command lists all databases in an InfluxDB Cloud
|
||||||
|
Dedicated cluster.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl database list [--format=table|json]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Flags
|
||||||
|
|
||||||
|
| Flag | | Description |
|
||||||
|
| :--- | :--------- | :---------------------------------------------------- |
|
||||||
|
| | `--format` | Output format (`table` or `json`, default is `table`) |
|
||||||
|
| `-h` | `--help` | Output command help |
|
|
@ -0,0 +1,19 @@
|
||||||
|
---
|
||||||
|
title: influxctl help
|
||||||
|
description: >
|
||||||
|
The `influxctl help` command outputs help information for the `influxctl`
|
||||||
|
command line interface.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: influxctl
|
||||||
|
weight: 202
|
||||||
|
---
|
||||||
|
|
||||||
|
The `influxctl help` command outputs help information for the `influxctl`
|
||||||
|
command line interface.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl help
|
||||||
|
```
|
|
@ -0,0 +1,25 @@
|
||||||
|
---
|
||||||
|
title: influxctl init
|
||||||
|
description: >
|
||||||
|
The `influxctl init` command starts an interactive prompt to set up a
|
||||||
|
connection profile.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: influxctl
|
||||||
|
weight: 202
|
||||||
|
---
|
||||||
|
|
||||||
|
The `influxctl init` command starts an interactive prompt to set up a
|
||||||
|
[connection profile](/influxdb/cloud-dedicated/reference/cli/influxctl/#configure-connection-profiles).
|
||||||
|
|
||||||
|
Provide the following for each profile:
|
||||||
|
|
||||||
|
- Profile name
|
||||||
|
- Account ID
|
||||||
|
- Cluster ID
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl init
|
||||||
|
```
|
|
@ -0,0 +1,33 @@
|
||||||
|
---
|
||||||
|
title: influxctl token
|
||||||
|
description: >
|
||||||
|
The `influx token` command and its subcommands manage database tokens in an
|
||||||
|
InfluxDB Cloud Dedicated cluster.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: influxctl
|
||||||
|
weight: 201
|
||||||
|
---
|
||||||
|
|
||||||
|
The `influx token` command and its subcommands manage database tokens in an
|
||||||
|
InfluxDB Cloud Dedicated cluster.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token [subcommand] [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Subcommands
|
||||||
|
|
||||||
|
| Subcommand | Description |
|
||||||
|
| :------------------------------------------------------------------------ | :---------------------- |
|
||||||
|
| [create](/influxdb/cloud-dedicated/reference/cli/influxctl/token/create/) | Create a database token |
|
||||||
|
| [list](/influxdb/cloud-dedicated/reference/cli/influxctl/token/list/) | List database tokens |
|
||||||
|
| [delete](/influxdb/cloud-dedicated/reference/cli/influxctl/token/delete/) | Delete a database token |
|
||||||
|
|
||||||
|
## Flags
|
||||||
|
|
||||||
|
| Flag | | Description |
|
||||||
|
| :--- | :------- | :------------------ |
|
||||||
|
| `-h` | `--help` | Output command help |
|
|
@ -0,0 +1,87 @@
|
||||||
|
---
|
||||||
|
title: influxctl token create
|
||||||
|
description: >
|
||||||
|
The `influxctl token create` command creates a database token with specified
|
||||||
|
permissions to resources in an InfluxDB Cloud Dedicated cluster.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: influxctl token
|
||||||
|
weight: 301
|
||||||
|
---
|
||||||
|
|
||||||
|
The `influxctl token create` command creates a database token with specified
|
||||||
|
permissions to resources in an InfluxDB Cloud Dedicated cluster and outputs
|
||||||
|
the token string.
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
#### Store secure tokens in a secret store
|
||||||
|
|
||||||
|
Token strings are returned _only_ on token creation.
|
||||||
|
We recommend storing database tokens in a secure secret store.
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token create \
|
||||||
|
[--read-database=<DATABASE_NAME>] \
|
||||||
|
[--write-database=<DATABASE_NAME>] \
|
||||||
|
<TOKEN_DESCRIPTION>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Arguments
|
||||||
|
|
||||||
|
| Argument | Description |
|
||||||
|
| :-------------------- | :------------------------- |
|
||||||
|
| **TOKEN_DESCRIPTION** | Database token description |
|
||||||
|
|
||||||
|
## Flags
|
||||||
|
|
||||||
|
| Flag | | Description |
|
||||||
|
| :--- | :----------------- | :------------------------------------ |
|
||||||
|
| `-h` | `--help` | Output command help |
|
||||||
|
| | `--read-database` | Grant read permissions to a database |
|
||||||
|
| | `--write-database` | Grant write permissions to a database |
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
- [Create a token with read and write access to a database](#create-a-token-with-read-and-write-access-to-a-database)
|
||||||
|
- [Create a token with read-only access to a database](#create-a-token-with-read-only-access-to-a-database)
|
||||||
|
- [Create a token with read-only access to multiple database](#create-a-token-with-read-only-access-to-multiple-database)
|
||||||
|
- [Create a token with mixed permissions on multiple database](#create-a-token-with-mixed-permissions-on-multiple-database)
|
||||||
|
|
||||||
|
##### Create a token with read and write access to a database
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token create \
|
||||||
|
--read-database mydb \
|
||||||
|
--write-database mydb \
|
||||||
|
"Read/write token for mydb"
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Create a token with read-only access to a database
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token create \
|
||||||
|
--read-database mydb \
|
||||||
|
"Read-only token for mydb"
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Create a token with read-only access to multiple database
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token create \
|
||||||
|
--read-database mydb1 \
|
||||||
|
--read-database mydb2 \
|
||||||
|
"Read-only token for mydb1 and mydb2"
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Create a token with mixed permissions on multiple database
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token create \
|
||||||
|
--read-database mydb1 \
|
||||||
|
--read-database mydb2 \
|
||||||
|
--write-database mydb2 \
|
||||||
|
"Read-only on mydb1, Read/write on mydb2"
|
||||||
|
```
|
|
@ -0,0 +1,50 @@
|
||||||
|
---
|
||||||
|
title: influxctl token delete
|
||||||
|
description: >
|
||||||
|
The `influxctl token delete` command deletes a database token from an InfluxDB
|
||||||
|
Cloud Dedicated cluster and revokes all permissions associated with the token.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: influxctl token
|
||||||
|
weight: 302
|
||||||
|
---
|
||||||
|
|
||||||
|
The `influxctl token delete` command deletes a database token from an InfluxDB
|
||||||
|
Cloud Dedicated cluster and revokes all permissions associated with the token.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token delete <TOKEN_ID>
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% warn %}}
|
||||||
|
#### Deleting a token is immediate and cannot be undone
|
||||||
|
|
||||||
|
Deleting a database token is a destructive action that takes place immediately
|
||||||
|
and cannot be undone.
|
||||||
|
|
||||||
|
#### Rotate deleted tokens
|
||||||
|
|
||||||
|
After deleting a database token, any clients using the deleted token need to be
|
||||||
|
updated with a new database token to continue to interact with your InfluxDB
|
||||||
|
Cloud Dedicated cluster.
|
||||||
|
{{% /warn %}}
|
||||||
|
|
||||||
|
## Arguments
|
||||||
|
|
||||||
|
| Argument | Description |
|
||||||
|
| :----------- | :-------------------------- |
|
||||||
|
| **TOKEN_ID** | Database token ID to delete |
|
||||||
|
|
||||||
|
## Flags
|
||||||
|
|
||||||
|
| Flag | | Description |
|
||||||
|
| :--- | :------- | :------------------ |
|
||||||
|
| `-h` | `--help` | Output command help |
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token delete 000xX0Xx00xX
|
||||||
|
```
|
|
@ -0,0 +1,26 @@
|
||||||
|
---
|
||||||
|
title: influxctl token list
|
||||||
|
description: >
|
||||||
|
The `influxctl token list` command lists all database tokens in an InfluxDB
|
||||||
|
Cloud Dedicated cluster.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: influxctl token
|
||||||
|
weight: 301
|
||||||
|
---
|
||||||
|
|
||||||
|
The `influxctl token list` command lists all database tokens in an InfluxDB Cloud
|
||||||
|
Dedicated cluster.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token list [--format=table|json]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Flags
|
||||||
|
|
||||||
|
| Flag | | Description |
|
||||||
|
| :--- | :--------- | :---------------------------------------------------- |
|
||||||
|
| | `--format` | Output format (`table` or `json`, default is `table`) |
|
||||||
|
| `-h` | `--help` | Output command help |
|
|
@ -0,0 +1,19 @@
|
||||||
|
---
|
||||||
|
title: influxctl version
|
||||||
|
description: >
|
||||||
|
The `influxctl version` command outputs the current version and architecture of
|
||||||
|
the `influxctl` command line interface.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: influxctl
|
||||||
|
weight: 202
|
||||||
|
---
|
||||||
|
|
||||||
|
The `influxctl version` command outputs the current version and architecture of
|
||||||
|
the `influxctl` command line interface.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl version
|
||||||
|
```
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
title: InfluxDB internals
|
||||||
|
description: >
|
||||||
|
Learn about internal systems and implementation details of InfluxDB Cloud Dedicated.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: Reference
|
||||||
|
weight: 108
|
||||||
|
---
|
||||||
|
|
||||||
|
{{< children >}}
|
|
@ -0,0 +1,68 @@
|
||||||
|
---
|
||||||
|
title: Arrow Flight SQL
|
||||||
|
description: >
|
||||||
|
The InfluxDB SQL implementation uses **Arrow Flight SQL** to query InfluxDB
|
||||||
|
and return results.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
parent: InfluxDB internals
|
||||||
|
weight: 101
|
||||||
|
related:
|
||||||
|
- /influxdb/cloud-dedicated/reference/sql/
|
||||||
|
---
|
||||||
|
|
||||||
|
The InfluxDB SQL implementation uses [Arrow Flight SQL](https://arrow.apache.org/docs/format/FlightSql.html)
|
||||||
|
to query InfluxDB and return results.
|
||||||
|
|
||||||
|
> Arrow Flight SQL is a protocol for interacting with SQL databases using the
|
||||||
|
> Arrow in-memory format and the [Flight RPC](https://arrow.apache.org/docs/format/Flight.html)
|
||||||
|
> framework.
|
||||||
|
>
|
||||||
|
> {{% cite %}}-- [Arrow Flight SQL documentation](https://arrow.apache.org/docs/format/FlightSql.html){{% /cite %}}
|
||||||
|
|
||||||
|
Flight SQL uses the RPC methods defined in the in Flight RPC framework and provides
|
||||||
|
various commands that pair those methods with request and response messages.
|
||||||
|
The InfluxDB Flight SQL implementation supports the following Flight SQL commands:
|
||||||
|
|
||||||
|
### Flight SQL metadata commands
|
||||||
|
|
||||||
|
{{% caption %}}
|
||||||
|
_For command descriptions, see the
|
||||||
|
[Arrow Flight SQL RPC methods documentation](https://arrow.apache.org/docs/format/FlightSql.html#sql-metadata)_.
|
||||||
|
{{% /caption %}}
|
||||||
|
|
||||||
|
| Message | Supported |
|
||||||
|
| :----------------------- | :----------------------: |
|
||||||
|
| CommandGetCatalogs | **{{% icon "check" %}}** |
|
||||||
|
| CommandGetDbSchemas | **{{% icon "check" %}}** |
|
||||||
|
| CommandGetTables | **{{% icon "check" %}}** |
|
||||||
|
| CommandGetTableTypes | **{{% icon "check" %}}** |
|
||||||
|
| CommandGetSqlInfo | **{{% icon "check" %}}** |
|
||||||
|
| CommandGetPrimaryKeys | **{{% icon "check" %}}** |
|
||||||
|
| CommandGetExportedKeys | **{{% icon "check" %}}** |
|
||||||
|
| CommandGetImportedKeys | **{{% icon "check" %}}** |
|
||||||
|
| CommandGetCrossReference | **{{% icon "check" %}}** |
|
||||||
|
| CommandGetXdbcTypeInfo | |
|
||||||
|
|
||||||
|
### Flight SQL query execution commands
|
||||||
|
|
||||||
|
{{% caption %}}
|
||||||
|
_For command descriptions, see the
|
||||||
|
[Arrow Flight SQL RPC methods documentation](https://arrow.apache.org/docs/format/FlightSql.html#query-execution)_.
|
||||||
|
{{% /caption %}}
|
||||||
|
|
||||||
|
| Message | Supported |
|
||||||
|
| :--------------------------------------- | :----------------------: |
|
||||||
|
| ActionCreatePreparedStatementRequest | |
|
||||||
|
| ActionCreatePreparedSubstraitPlanRequest | |
|
||||||
|
| ActionClosePreparedStatementRequest | |
|
||||||
|
| ActionBeginTransactionRequest | |
|
||||||
|
| ActionBeginSavepointRequest | |
|
||||||
|
| ActionBeginSavepointResult | |
|
||||||
|
| ActionEndTransactionRequest | |
|
||||||
|
| ActionEndSavepointRequest | |
|
||||||
|
| CommandStatementQuery | **{{% icon "check" %}}** |
|
||||||
|
| CommandStatementSubstraitPlan | |
|
||||||
|
| CommandPreparedStatementQuery | **{{% icon "check" %}}** |
|
||||||
|
| CommandPreparedStatementUpdate | |
|
||||||
|
| ActionCancelQueryRequest | |
|
|
@ -3,13 +3,15 @@ title: SQL reference documentation
|
||||||
description: >
|
description: >
|
||||||
Learn the SQL syntax and structure used to query InfluxDB.
|
Learn the SQL syntax and structure used to query InfluxDB.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: SQL reference
|
name: SQL reference
|
||||||
parent: Reference
|
parent: Reference
|
||||||
weight: 101
|
weight: 101
|
||||||
|
related:
|
||||||
|
- /influxdb/cloud-dedicated/reference/internals/arrow-flightsql/
|
||||||
---
|
---
|
||||||
|
|
||||||
InfluxDB Cloud backed by InfluxDB IOx uses the [Apache Arrow DataFusion](https://arrow.apache.org/datafusion/) implementation of SQL.
|
InfluxDB Cloud Dedicated uses the [Apache Arrow DataFusion](https://arrow.apache.org/datafusion/) implementation of SQL.
|
||||||
|
|
||||||
- [Identifiers](#identifiers)
|
- [Identifiers](#identifiers)
|
||||||
- [Quoting and case sensitivity](#quoting-and-case-sensitivity)
|
- [Quoting and case sensitivity](#quoting-and-case-sensitivity)
|
|
@ -5,15 +5,15 @@ description: >
|
||||||
The InfluxDB SQL implementation supports a number of data types including 64-bit integers,
|
The InfluxDB SQL implementation supports a number of data types including 64-bit integers,
|
||||||
double-precision floating point numbers, strings, and more.
|
double-precision floating point numbers, strings, and more.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: Data types
|
name: Data types
|
||||||
parent: SQL reference
|
parent: SQL reference
|
||||||
weight: 200
|
weight: 200
|
||||||
related:
|
related:
|
||||||
- /influxdb/cloud-iox/query-data/sql/cast-types/
|
- /influxdb/cloud-dedicated/query-data/sql/cast-types/
|
||||||
---
|
---
|
||||||
|
|
||||||
InfluxDB Cloud backed by InfluxDB IOx uses the [Apache Arrow DataFusion](https://arrow.apache.org/datafusion/) implementation of SQL.
|
InfluxDB Cloud Dedicated uses the [Apache Arrow DataFusion](https://arrow.apache.org/datafusion/) implementation of SQL.
|
||||||
Data types define the type of values that can be stored in table columns.
|
Data types define the type of values that can be stored in table columns.
|
||||||
In InfluxDB's SQL implementation, a **measurement** is structured as a table,
|
In InfluxDB's SQL implementation, a **measurement** is structured as a table,
|
||||||
and **tags**, **fields** and **timestamps** are exposed as columns.
|
and **tags**, **fields** and **timestamps** are exposed as columns.
|
|
@ -4,7 +4,7 @@ description: >
|
||||||
The `EXPLAIN` command shows the logical and physical execution plan for the
|
The `EXPLAIN` command shows the logical and physical execution plan for the
|
||||||
specified SQL statement.
|
specified SQL statement.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: EXPLAIN command
|
name: EXPLAIN command
|
||||||
parent: SQL reference
|
parent: SQL reference
|
||||||
weight: 207
|
weight: 207
|
|
@ -4,7 +4,7 @@ list_title: Functions
|
||||||
description: >
|
description: >
|
||||||
Use SQL functions to transform queried values.
|
Use SQL functions to transform queried values.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: Functions
|
name: Functions
|
||||||
parent: SQL reference
|
parent: SQL reference
|
||||||
identifier: sql-functions
|
identifier: sql-functions
|
|
@ -4,12 +4,12 @@ list_title: Aggregate functions
|
||||||
description: >
|
description: >
|
||||||
Aggregate data with SQL aggregate functions.
|
Aggregate data with SQL aggregate functions.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: Aggregate
|
name: Aggregate
|
||||||
parent: sql-functions
|
parent: sql-functions
|
||||||
weight: 301
|
weight: 301
|
||||||
related:
|
related:
|
||||||
- /influxdb/cloud-iox/query-data/sql/aggregate-select/
|
- /influxdb/cloud-dedicated/query-data/sql/aggregate-select/
|
||||||
---
|
---
|
||||||
|
|
||||||
SQL aggregate functions aggregate values in a specified column for each
|
SQL aggregate functions aggregate values in a specified column for each
|
||||||
|
@ -131,7 +131,7 @@ max(expression)
|
||||||
```
|
```
|
||||||
|
|
||||||
_To return both the maximum value and its associated timestamp, use
|
_To return both the maximum value and its associated timestamp, use
|
||||||
[`selector_max`](/influxdb/cloud-iox/reference/sql/functions/selector/#selector_max)._
|
[`selector_max`](/influxdb/cloud-dedicated/reference/sql/functions/selector/#selector_max)._
|
||||||
|
|
||||||
##### Arguments
|
##### Arguments
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ min(expression)
|
||||||
```
|
```
|
||||||
|
|
||||||
_To return both the minimum value and its associated timestamp, use
|
_To return both the minimum value and its associated timestamp, use
|
||||||
[`selector_max`](/influxdb/cloud-iox/reference/sql/functions/selector/#selector_min)._
|
[`selector_max`](/influxdb/cloud-dedicated/reference/sql/functions/selector/#selector_min)._
|
||||||
|
|
||||||
##### Arguments
|
##### Arguments
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ corr(expression1, expression2)
|
||||||
{{% expand "View `corr` query example" %}}
|
{{% expand "View `corr` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -294,7 +294,7 @@ covar(expression1, expression2)
|
||||||
{{% expand "View `covar` query example" %}}
|
{{% expand "View `covar` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -329,7 +329,7 @@ covar_pop(expression1, expression2)
|
||||||
{{% expand "View `covar_pop` query example" %}}
|
{{% expand "View `covar_pop` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -364,7 +364,7 @@ covar_samp(expression1, expression2)
|
||||||
{{% expand "View `covar_samp` query example" %}}
|
{{% expand "View `covar_samp` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -399,7 +399,7 @@ stddev(expression)
|
||||||
{{% expand "View `stddev` query example" %}}
|
{{% expand "View `stddev` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -434,7 +434,7 @@ stddev_pop(expression)
|
||||||
{{% expand "View `stddev_pop` query example" %}}
|
{{% expand "View `stddev_pop` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -469,7 +469,7 @@ stddev_samp(expression)
|
||||||
{{% expand "View `stddev_samp` query example" %}}
|
{{% expand "View `stddev_samp` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -504,7 +504,7 @@ var(expression)
|
||||||
{{% expand "View `var` query example" %}}
|
{{% expand "View `var` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -539,7 +539,7 @@ var_pop(expression)
|
||||||
{{% expand "View `var_pop` query example" %}}
|
{{% expand "View `var_pop` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -574,7 +574,7 @@ var_samp(expression)
|
||||||
{{% expand "View `var_samp` query example" %}}
|
{{% expand "View `var_samp` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -617,7 +617,7 @@ approx_distinct(expression)
|
||||||
{{% expand "View `approx_distinct` query example" %}}
|
{{% expand "View `approx_distinct` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -653,7 +653,7 @@ approx_median(expression)
|
||||||
{{% expand "View `approx_median` query example" %}}
|
{{% expand "View `approx_median` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -694,7 +694,7 @@ approx_percentile_cont(expression, percentile, centroids)
|
||||||
{{% expand "View `approx_percentile_cont` query example" %}}
|
{{% expand "View `approx_percentile_cont` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -733,7 +733,7 @@ approx_percentile_cont_with_weight(expression, weight, percentile)
|
||||||
{{% expand "View `approx_percentile_cont_with_weight` query example" %}}
|
{{% expand "View `approx_percentile_cont_with_weight` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
|
@ -4,7 +4,7 @@ list_title: Conditional functions
|
||||||
description: >
|
description: >
|
||||||
Use conditional functions to conditionally handle null values in SQL queries.
|
Use conditional functions to conditionally handle null values in SQL queries.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: Conditional
|
name: Conditional
|
||||||
parent: sql-functions
|
parent: sql-functions
|
||||||
weight: 306
|
weight: 306
|
|
@ -4,7 +4,7 @@ list_title: Math functions
|
||||||
description: >
|
description: >
|
||||||
Use math functions to perform mathematical operations in SQL queries.
|
Use math functions to perform mathematical operations in SQL queries.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: Math
|
name: Math
|
||||||
parent: sql-functions
|
parent: sql-functions
|
||||||
weight: 306
|
weight: 306
|
||||||
|
@ -51,7 +51,7 @@ abs(numeric_expression)
|
||||||
{{% expand "View `abs` query example" %}}
|
{{% expand "View `abs` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT abs(temp) AS abs FROM home LIMIT 3
|
SELECT abs(temp) AS abs FROM home LIMIT 3
|
||||||
|
@ -83,7 +83,7 @@ acos(numeric_expression)
|
||||||
{{% expand "View `acos` query example" %}}
|
{{% expand "View `acos` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT acos(temp * .01) AS acos FROM home LIMIT 3
|
SELECT acos(temp * .01) AS acos FROM home LIMIT 3
|
||||||
|
@ -115,7 +115,7 @@ asin(numeric_expression)
|
||||||
{{% expand "View `asin` query example" %}}
|
{{% expand "View `asin` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT asin(temp * .01) AS asin FROM home LIMIT 3
|
SELECT asin(temp * .01) AS asin FROM home LIMIT 3
|
||||||
|
@ -147,7 +147,7 @@ atan(numeric_expression)
|
||||||
{{% expand "View `atan` query example" %}}
|
{{% expand "View `atan` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT atan(temp * .01) AS atan FROM home LIMIT 3
|
SELECT atan(temp * .01) AS atan FROM home LIMIT 3
|
||||||
|
@ -181,7 +181,7 @@ atan2(expression_y, expression_x)
|
||||||
{{% expand "View `atan2` query example" %}}
|
{{% expand "View `atan2` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT atan2(temp, hum) AS atan2 FROM home LIMIT 3
|
SELECT atan2(temp, hum) AS atan2 FROM home LIMIT 3
|
||||||
|
@ -213,7 +213,7 @@ ceil(numeric_expression)
|
||||||
{{% expand "View `ceil` query example" %}}
|
{{% expand "View `ceil` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT ceil(temp) AS ceil FROM home LIMIT 3
|
SELECT ceil(temp) AS ceil FROM home LIMIT 3
|
||||||
|
@ -245,7 +245,7 @@ cos(numeric_expression)
|
||||||
{{% expand "View `cos` query example" %}}
|
{{% expand "View `cos` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT cos(temp) AS cos FROM home LIMIT 3
|
SELECT cos(temp) AS cos FROM home LIMIT 3
|
||||||
|
@ -277,7 +277,7 @@ exp(numeric_expression)
|
||||||
{{% expand "View `exp` query example" %}}
|
{{% expand "View `exp` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT exp(temp) AS exp FROM home LIMIT 3
|
SELECT exp(temp) AS exp FROM home LIMIT 3
|
||||||
|
@ -309,7 +309,7 @@ floor(numeric_expression)
|
||||||
{{% expand "View `floor` query example" %}}
|
{{% expand "View `floor` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT floor(temp) AS floor FROM home LIMIT 3
|
SELECT floor(temp) AS floor FROM home LIMIT 3
|
||||||
|
@ -341,7 +341,7 @@ ln(numeric_expression)
|
||||||
{{% expand "View `ln` query example" %}}
|
{{% expand "View `ln` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT ln(temp) AS ln FROM home LIMIT 3
|
SELECT ln(temp) AS ln FROM home LIMIT 3
|
||||||
|
@ -373,7 +373,7 @@ log10(numeric_expression)
|
||||||
{{% expand "View `log10` query example" %}}
|
{{% expand "View `log10` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT log10(temp) AS log10 FROM home LIMIT 3
|
SELECT log10(temp) AS log10 FROM home LIMIT 3
|
||||||
|
@ -405,7 +405,7 @@ log2(numeric_expression)
|
||||||
{{% expand "View `log2` query example" %}}
|
{{% expand "View `log2` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT log2(temp) AS log2 FROM home LIMIT 3
|
SELECT log2(temp) AS log2 FROM home LIMIT 3
|
||||||
|
@ -439,7 +439,7 @@ power(base, exponent)
|
||||||
{{% expand "View `power` query example" %}}
|
{{% expand "View `power` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT power(temp, hum * .1) AS power FROM home LIMIT 3
|
SELECT power(temp, hum * .1) AS power FROM home LIMIT 3
|
||||||
|
@ -467,7 +467,7 @@ random()
|
||||||
{{% expand "View `random` query example" %}}
|
{{% expand "View `random` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT temp * random() AS random FROM home LIMIT 3
|
SELECT temp * random() AS random FROM home LIMIT 3
|
||||||
|
@ -503,7 +503,7 @@ round(numeric_expression)
|
||||||
{{% expand "View `round` query example" %}}
|
{{% expand "View `round` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT round(temp) AS round FROM home LIMIT 3
|
SELECT round(temp) AS round FROM home LIMIT 3
|
||||||
|
@ -537,7 +537,7 @@ signum(numeric_expression)
|
||||||
{{% expand "View `signum` query example" %}}
|
{{% expand "View `signum` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT signum(temp - 23) AS signum FROM home LIMIT 3
|
SELECT signum(temp - 23) AS signum FROM home LIMIT 3
|
||||||
|
@ -569,7 +569,7 @@ sin(numeric_expression)
|
||||||
{{% expand "View `sin` query example" %}}
|
{{% expand "View `sin` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT sin(temp) AS sin FROM home LIMIT 3
|
SELECT sin(temp) AS sin FROM home LIMIT 3
|
||||||
|
@ -601,7 +601,7 @@ sqrt(numeric_expression)
|
||||||
{{% expand "View `sqrt` query example" %}}
|
{{% expand "View `sqrt` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT sqrt(temp) AS sqrt FROM home LIMIT 3
|
SELECT sqrt(temp) AS sqrt FROM home LIMIT 3
|
||||||
|
@ -633,7 +633,7 @@ tan(numeric_expression)
|
||||||
{{% expand "View `tan` query example" %}}
|
{{% expand "View `tan` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT tan(temp) AS tan FROM home LIMIT 3
|
SELECT tan(temp) AS tan FROM home LIMIT 3
|
||||||
|
@ -665,7 +665,7 @@ trunc(numeric_expression)
|
||||||
{{% expand "View `trunc` query example" %}}
|
{{% expand "View `trunc` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT trunc(temp) AS trunc FROM home LIMIT 3
|
SELECT trunc(temp) AS trunc FROM home LIMIT 3
|
|
@ -4,7 +4,7 @@ list_title: Miscellaneous functions
|
||||||
description: >
|
description: >
|
||||||
Use miscellaneous SQL functions to perform a variety of operations in SQL queries.
|
Use miscellaneous SQL functions to perform a variety of operations in SQL queries.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: Miscellaneous
|
name: Miscellaneous
|
||||||
parent: sql-functions
|
parent: sql-functions
|
||||||
weight: 310
|
weight: 310
|
||||||
|
@ -37,7 +37,7 @@ arrow_cast(expression, datatype)
|
||||||
{{% expand "View `arrow_cast` query example" %}}
|
{{% expand "View `arrow_cast` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -74,7 +74,7 @@ arrow_typeof(expression)
|
||||||
{{% expand "View `arrow_typeof` query example" %}}
|
{{% expand "View `arrow_typeof` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
|
@ -4,11 +4,11 @@ list_title: Regular expression functions
|
||||||
description: >
|
description: >
|
||||||
Use regular expression functions to operate on data in SQL queries.
|
Use regular expression functions to operate on data in SQL queries.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: Regular expression
|
name: Regular expression
|
||||||
parent: sql-functions
|
parent: sql-functions
|
||||||
weight: 308
|
weight: 308
|
||||||
influxdb/cloud-iox/tags: [regular expressions, sql]
|
influxdb/cloud-dedicated/tags: [regular expressions, sql]
|
||||||
---
|
---
|
||||||
|
|
||||||
The InfluxDB SQL implementation uses the POSIX regular expression syntax and
|
The InfluxDB SQL implementation uses the POSIX regular expression syntax and
|
||||||
|
@ -39,7 +39,7 @@ regexp_match(str, regexp, flags)
|
||||||
{{% expand "View `regexp_replace` query example" %}}
|
{{% expand "View `regexp_replace` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
{{% note %}}
|
{{% note %}}
|
||||||
`regexp_match` returns a _list_ Arrow type, which is not supported by InfluxDB.
|
`regexp_match` returns a _list_ Arrow type, which is not supported by InfluxDB.
|
||||||
|
@ -87,7 +87,7 @@ regexp_replace(str, regexp, replacement, flags)
|
||||||
{{% expand "View `regexp_replace` query example" %}}
|
{{% expand "View `regexp_replace` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
|
@ -4,12 +4,12 @@ list_title: Selector functions
|
||||||
description: >
|
description: >
|
||||||
Select data with SQL selector functions.
|
Select data with SQL selector functions.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: Selector
|
name: Selector
|
||||||
parent: sql-functions
|
parent: sql-functions
|
||||||
weight: 302
|
weight: 302
|
||||||
related:
|
related:
|
||||||
- /influxdb/cloud-iox/query-data/sql/aggregate-select/
|
- /influxdb/cloud-dedicated/query-data/sql/aggregate-select/
|
||||||
---
|
---
|
||||||
|
|
||||||
SQL selector functions are designed to work with time series data.
|
SQL selector functions are designed to work with time series data.
|
|
@ -4,7 +4,7 @@ list_title: String functions
|
||||||
description: >
|
description: >
|
||||||
Use string functions to operate on string values in SQL queries.
|
Use string functions to operate on string values in SQL queries.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: String
|
name: String
|
||||||
parent: sql-functions
|
parent: sql-functions
|
||||||
weight: 307
|
weight: 307
|
||||||
|
@ -50,7 +50,7 @@ Returns the ASCII value of the first character in a string.
|
||||||
|
|
||||||
{{% note %}}
|
{{% note %}}
|
||||||
`ascii` returns a 32-bit integer.
|
`ascii` returns a 32-bit integer.
|
||||||
To use with InfluxDB, [cast the return value to 64-bit integer](/influxdb/cloud-iox/query-data/sql/cast-types/#cast-to-an-integer).
|
To use with InfluxDB, [cast the return value to 64-bit integer](/influxdb/cloud-dedicated/query-data/sql/cast-types/#cast-to-an-integer).
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
|
@ -70,7 +70,7 @@ ascii(str)
|
||||||
{{% expand "View `ascii` query example" %}}
|
{{% expand "View `ascii` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
@ -93,7 +93,7 @@ Returns the bit length of a string.
|
||||||
|
|
||||||
{{% note %}}
|
{{% note %}}
|
||||||
`bit_length` returns a 32-bit integer.
|
`bit_length` returns a 32-bit integer.
|
||||||
To use with InfluxDB, [cast the return value to 64-bit integer](/influxdb/cloud-iox/query-data/sql/cast-types/#cast-to-an-integer).
|
To use with InfluxDB, [cast the return value to 64-bit integer](/influxdb/cloud-dedicated/query-data/sql/cast-types/#cast-to-an-integer).
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
|
@ -113,7 +113,7 @@ bit_length(str)
|
||||||
{{% expand "View `bit_length` query example" %}}
|
{{% expand "View `bit_length` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
@ -158,7 +158,7 @@ btrim(str[, trim_str])
|
||||||
{{% expand "View `btrim` query example" %}}
|
{{% expand "View `btrim` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
@ -205,7 +205,7 @@ concat(str[, ..., str_n])
|
||||||
{{% expand "View `concat` query example" %}}
|
{{% expand "View `concat` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -251,7 +251,7 @@ concat(separator, str[, ..., str_n])
|
||||||
{{% expand "View `concat_ws` query example" %}}
|
{{% expand "View `concat_ws` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -378,7 +378,7 @@ left(str, n)
|
||||||
{{% expand "View `left` query example" %}}
|
{{% expand "View `left` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
@ -401,7 +401,7 @@ Returns the number of characters in a string.
|
||||||
|
|
||||||
{{% note %}}
|
{{% note %}}
|
||||||
`char_length` returns a 32-bit integer.
|
`char_length` returns a 32-bit integer.
|
||||||
To use with InfluxDB, [cast the return value to 64-bit integer](/influxdb/cloud-iox/query-data/sql/cast-types/#cast-to-an-integer).
|
To use with InfluxDB, [cast the return value to 64-bit integer](/influxdb/cloud-dedicated/query-data/sql/cast-types/#cast-to-an-integer).
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
|
@ -427,7 +427,7 @@ length(str)
|
||||||
{{% expand "View `length` query example" %}}
|
{{% expand "View `length` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
@ -466,7 +466,7 @@ lower(str)
|
||||||
{{% expand "View `lower` query example" %}}
|
{{% expand "View `lower` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
@ -508,7 +508,7 @@ lpad(str, n[, padding_str])
|
||||||
{{% expand "View `lpad` query example" %}}
|
{{% expand "View `lpad` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
@ -584,7 +584,7 @@ md5(str)
|
||||||
{{% expand "View `md5` query example" %}}
|
{{% expand "View `md5` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
@ -607,7 +607,7 @@ Returns the length of a string in bytes.
|
||||||
|
|
||||||
{{% note %}}
|
{{% note %}}
|
||||||
`length` returns a 32-bit integer.
|
`length` returns a 32-bit integer.
|
||||||
To use with InfluxDB, [cast the return value to 64-bit integer](/influxdb/cloud-iox/query-data/sql/cast-types/#cast-to-an-integer).
|
To use with InfluxDB, [cast the return value to 64-bit integer](/influxdb/cloud-dedicated/query-data/sql/cast-types/#cast-to-an-integer).
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
|
@ -628,7 +628,7 @@ octet_length(str)
|
||||||
{{% expand "View `octet_length` query example" %}}
|
{{% expand "View `octet_length` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
@ -703,7 +703,7 @@ replace(str, substr, replacement)
|
||||||
{{% expand "View `replace` query example" %}}
|
{{% expand "View `replace` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
@ -737,7 +737,7 @@ reverse(str)
|
||||||
{{% expand "View `reverse` query example" %}}
|
{{% expand "View `reverse` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
@ -776,7 +776,7 @@ right(str, n)
|
||||||
{{% expand "View `right` query example" %}}
|
{{% expand "View `right` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
@ -817,7 +817,7 @@ rpad(str, n[, padding_str])
|
||||||
{{% expand "View `rpad` query example" %}}
|
{{% expand "View `rpad` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
@ -933,7 +933,7 @@ starts_with(str, substr)
|
||||||
{{% expand "View `starts_with` query example" %}}
|
{{% expand "View `starts_with` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
@ -958,7 +958,7 @@ If the substring does not exist in the string, the function returns 0.
|
||||||
|
|
||||||
{{% note %}}
|
{{% note %}}
|
||||||
`strpos` returns a 32-bit integer.
|
`strpos` returns a 32-bit integer.
|
||||||
To use with InfluxDB, [cast the return value to 64-bit integer](/influxdb/cloud-iox/query-data/sql/cast-types/#cast-to-an-integer).
|
To use with InfluxDB, [cast the return value to 64-bit integer](/influxdb/cloud-dedicated/query-data/sql/cast-types/#cast-to-an-integer).
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
|
@ -976,7 +976,7 @@ strpos(str, substr)
|
||||||
{{% expand "View `strpos` query example" %}}
|
{{% expand "View `strpos` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
@ -1015,7 +1015,7 @@ substr(str, start_pos[, length])
|
||||||
{{% expand "View `substr` query example" %}}
|
{{% expand "View `substr` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
@ -1050,7 +1050,7 @@ translate(str, chars, translation)
|
||||||
{{% expand "View `translate` query example" %}}
|
{{% expand "View `translate` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
@ -1167,7 +1167,7 @@ upper(str)
|
||||||
{{% expand "View `upper` query example" %}}
|
{{% expand "View `upper` query example" %}}
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
|
@ -4,7 +4,7 @@ list_title: Time and date functions
|
||||||
description: >
|
description: >
|
||||||
Use time and date functions to work with time values and time series data.
|
Use time and date functions to work with time values and time series data.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: Time and date
|
name: Time and date
|
||||||
parent: sql-functions
|
parent: sql-functions
|
||||||
weight: 305
|
weight: 305
|
||||||
|
@ -298,7 +298,7 @@ LIMIT 1
|
||||||
|
|
||||||
Converts a value to RFC3339 nanosecond timestamp format (`YYYY-MM-DDT00:00:00.000000000Z`).
|
Converts a value to RFC3339 nanosecond timestamp format (`YYYY-MM-DDT00:00:00.000000000Z`).
|
||||||
Supports timestamp, integer, and unsigned integer types as input.
|
Supports timestamp, integer, and unsigned integer types as input.
|
||||||
Integers and unsigned integers are parsed as [Unix nanosecond timestamps](/influxdb/cloud-iox/reference/glossary/#unix-timestamp)
|
Integers and unsigned integers are parsed as [Unix nanosecond timestamps](/influxdb/cloud-dedicated/reference/glossary/#unix-timestamp)
|
||||||
and return the corresponding RFC3339 nanosecond timestamp.
|
and return the corresponding RFC3339 nanosecond timestamp.
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
|
@ -330,7 +330,7 @@ LIMIT 1
|
||||||
|
|
||||||
Converts a value to RFC3339 millisecond timestamp format (`YYYY-MM-DDT00:00:00.000Z`).
|
Converts a value to RFC3339 millisecond timestamp format (`YYYY-MM-DDT00:00:00.000Z`).
|
||||||
Supports timestamp, integer, and unsigned integer types as input.
|
Supports timestamp, integer, and unsigned integer types as input.
|
||||||
Integers and unsigned integers are parsed as [Unix nanosecond timestamps](/influxdb/cloud-iox/reference/glossary/#unix-timestamp)
|
Integers and unsigned integers are parsed as [Unix nanosecond timestamps](/influxdb/cloud-dedicated/reference/glossary/#unix-timestamp)
|
||||||
and return the corresponding RFC3339 timestamp.
|
and return the corresponding RFC3339 timestamp.
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
|
@ -365,7 +365,7 @@ Results
|
||||||
|
|
||||||
Converts a value to RFC3339 microsecond timestamp format (`YYYY-MM-DDT00:00:00.000000Z`).
|
Converts a value to RFC3339 microsecond timestamp format (`YYYY-MM-DDT00:00:00.000000Z`).
|
||||||
Supports timestamp, integer, and unsigned integer types as input.
|
Supports timestamp, integer, and unsigned integer types as input.
|
||||||
Integers and unsigned integers are parsed as [Unix nanosecond timestamps](/influxdb/cloud-iox/reference/glossary/#unix-timestamp)
|
Integers and unsigned integers are parsed as [Unix nanosecond timestamps](/influxdb/cloud-dedicated/reference/glossary/#unix-timestamp)
|
||||||
and return the corresponding RFC3339 timestamp.
|
and return the corresponding RFC3339 timestamp.
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
|
@ -398,7 +398,7 @@ LIMIT 1
|
||||||
|
|
||||||
Converts a value to RFC3339 second timestamp format (`YYYY-MM-DDT00:00:00Z`).
|
Converts a value to RFC3339 second timestamp format (`YYYY-MM-DDT00:00:00Z`).
|
||||||
Supports timestamp, integer, and unsigned integer types as input.
|
Supports timestamp, integer, and unsigned integer types as input.
|
||||||
Integers and unsigned integers are parsed as [Unix nanosecond timestamps](/influxdb/cloud-iox/reference/glossary/#unix-timestamp)
|
Integers and unsigned integers are parsed as [Unix nanosecond timestamps](/influxdb/cloud-dedicated/reference/glossary/#unix-timestamp)
|
||||||
and return the corresponding RFC3339 timestamp.
|
and return the corresponding RFC3339 timestamp.
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
|
@ -432,7 +432,7 @@ LIMIT 1;
|
||||||
### from_unixtime
|
### from_unixtime
|
||||||
|
|
||||||
Converts an integer to RFC3339 timestamp format (`YYYY-MM-DDT00:00:00.000000000Z`).
|
Converts an integer to RFC3339 timestamp format (`YYYY-MM-DDT00:00:00.000000000Z`).
|
||||||
Input is parsed as a [Unix nanosecond timestamp](/influxdb/cloud-iox/reference/glossary/#unix-timestamp)
|
Input is parsed as a [Unix nanosecond timestamp](/influxdb/cloud-dedicated/reference/glossary/#unix-timestamp)
|
||||||
and returns the corresponding RFC3339 timestamp.
|
and returns the corresponding RFC3339 timestamp.
|
||||||
|
|
||||||
```sql
|
```sql
|
|
@ -3,7 +3,7 @@ title: GROUP BY clause
|
||||||
description: >
|
description: >
|
||||||
Use the `GROUP BY` clause to group query data by column values.
|
Use the `GROUP BY` clause to group query data by column values.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: GROUP BY clause
|
name: GROUP BY clause
|
||||||
parent: SQL reference
|
parent: SQL reference
|
||||||
weight: 203
|
weight: 203
|
|
@ -4,7 +4,7 @@ description: >
|
||||||
Use the `HAVING` clause to filter query results based on values returned from
|
Use the `HAVING` clause to filter query results based on values returned from
|
||||||
an aggregate operation.
|
an aggregate operation.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: HAVING clause
|
name: HAVING clause
|
||||||
parent: SQL reference
|
parent: SQL reference
|
||||||
weight: 205
|
weight: 205
|
|
@ -4,7 +4,7 @@ description: >
|
||||||
The `SHOW TABLES`, `SHOW COLUMNS`, and `SHOW ALL` commands return metadata related to
|
The `SHOW TABLES`, `SHOW COLUMNS`, and `SHOW ALL` commands return metadata related to
|
||||||
your data schema.
|
your data schema.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
parent: SQL reference
|
parent: SQL reference
|
||||||
weight: 210
|
weight: 210
|
||||||
---
|
---
|
||||||
|
@ -16,9 +16,9 @@ To access this information, use the `SHOW TABLES`, `SHOW COLUMNS`, and
|
||||||
`SHOW ALL` commands or query views in the [ISO](https://www.iso.org/) SQL
|
`SHOW ALL` commands or query views in the [ISO](https://www.iso.org/) SQL
|
||||||
`information_schema` schema.
|
`information_schema` schema.
|
||||||
|
|
||||||
In the context of InfluxDB, a [measurement](/influxdb/cloud-iox/reference/glossary/#measurement)
|
In the context of InfluxDB, a [measurement](/influxdb/cloud-dedicated/reference/glossary/#measurement)
|
||||||
is represented as a table. Time, [tags](/influxdb/cloud-iox/reference/glossary/#tag),
|
is represented as a table. Time, [tags](/influxdb/cloud-dedicated/reference/glossary/#tag),
|
||||||
and [fields](/influxdb/cloud-iox/reference/glossary/#field) are each represented
|
and [fields](/influxdb/cloud-dedicated/reference/glossary/#field) are each represented
|
||||||
by columns in a table.
|
by columns in a table.
|
||||||
|
|
||||||
- [SHOW TABLES](#show-tables)
|
- [SHOW TABLES](#show-tables)
|
|
@ -3,7 +3,7 @@ title: LIMIT clause
|
||||||
description: >
|
description: >
|
||||||
Use the `LIMIT` clause to limit the number of results returned by a query.
|
Use the `LIMIT` clause to limit the number of results returned by a query.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: LIMIT clause
|
name: LIMIT clause
|
||||||
parent: SQL reference
|
parent: SQL reference
|
||||||
weight: 206
|
weight: 206
|
|
@ -4,7 +4,7 @@ list_title: ORDER BY clause
|
||||||
description: >
|
description: >
|
||||||
Use the `ORDER BY` clause to sort results by specified columns and order.
|
Use the `ORDER BY` clause to sort results by specified columns and order.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: ORDER BY clause
|
name: ORDER BY clause
|
||||||
parent: SQL reference
|
parent: SQL reference
|
||||||
weight: 204
|
weight: 204
|
||||||
|
@ -94,3 +94,5 @@ first by `location` (1), and second by `water_level` (2).
|
||||||
| coyote_creek | 2019-08-29T15:24:00.000Z | -0.571 |
|
| coyote_creek | 2019-08-29T15:24:00.000Z | -0.571 |
|
||||||
| coyote_creek | 2019-08-27T13:42:00.000Z | -0.561 |
|
| coyote_creek | 2019-08-27T13:42:00.000Z | -0.561 |
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
{{< /expand-wrapper >}}
|
|
@ -3,7 +3,7 @@ title: SELECT statement
|
||||||
description: >
|
description: >
|
||||||
Use the SQL `SELECT` statement to query data from a measurement.
|
Use the SQL `SELECT` statement to query data from a measurement.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: SELECT statement
|
name: SELECT statement
|
||||||
parent: SQL reference
|
parent: SQL reference
|
||||||
weight: 201
|
weight: 201
|
|
@ -4,7 +4,7 @@ description: >
|
||||||
The table value constructor (TVC) uses the `VALUES` keyword to specify a set of
|
The table value constructor (TVC) uses the `VALUES` keyword to specify a set of
|
||||||
row value expressions to construct into a table.
|
row value expressions to construct into a table.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
parent: SQL reference
|
parent: SQL reference
|
||||||
weight: 220
|
weight: 220
|
||||||
---
|
---
|
||||||
|
@ -66,7 +66,7 @@ FROM
|
||||||
<!-- ### Join data with an ad hoc table
|
<!-- ### Join data with an ad hoc table
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT
|
SELECT
|
|
@ -4,7 +4,7 @@ description: >
|
||||||
The `UNION` clause combines the results of two or more `SELECT` statements into
|
The `UNION` clause combines the results of two or more `SELECT` statements into
|
||||||
a single result set.
|
a single result set.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: UNION clause
|
name: UNION clause
|
||||||
parent: SQL reference
|
parent: SQL reference
|
||||||
weight: 206
|
weight: 206
|
||||||
|
@ -80,7 +80,7 @@ UNION
|
||||||
### Return the highest and lowest three results in a single result set
|
### Return the highest and lowest three results in a single result set
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol)._
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol)._
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
(
|
(
|
||||||
|
@ -122,8 +122,8 @@ UNION
|
||||||
### Union query results with custom data
|
### Union query results with custom data
|
||||||
|
|
||||||
_The following example uses the sample data set provided in
|
_The following example uses the sample data set provided in
|
||||||
[Get started with InfluxDB tutorial](/influxdb/cloud-iox/get-started/write/#construct-line-protocol).
|
[Get started with InfluxDB tutorial](/influxdb/cloud-dedicated/get-started/write/#construct-line-protocol).
|
||||||
It also uses the [table value constructor](/influxdb/cloud-iox/reference/sql/table-value-constructor/)
|
It also uses the [table value constructor](/influxdb/cloud-dedicated/reference/sql/table-value-constructor/)
|
||||||
to build a table with custom data._
|
to build a table with custom data._
|
||||||
|
|
||||||
```sql
|
```sql
|
|
@ -4,7 +4,7 @@ list_title: WHERE clause
|
||||||
description: >
|
description: >
|
||||||
Use the `WHERE` clause to filter results based on fields, tags, or timestamps.
|
Use the `WHERE` clause to filter results based on fields, tags, or timestamps.
|
||||||
menu:
|
menu:
|
||||||
influxdb_cloud_iox:
|
influxdb_cloud_dedicated:
|
||||||
name: WHERE clause
|
name: WHERE clause
|
||||||
parent: SQL reference
|
parent: SQL reference
|
||||||
weight: 202
|
weight: 202
|
|
@ -0,0 +1,14 @@
|
||||||
|
---
|
||||||
|
title: InfluxDB syntaxes
|
||||||
|
description: >
|
||||||
|
InfluxDB uses a handful of languages and syntaxes to perform tasks such as
|
||||||
|
writing, querying, and processing data.
|
||||||
|
weight: 105
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Other syntaxes
|
||||||
|
parent: Reference
|
||||||
|
influxdb/cloud-dedicated/tags: [syntax]
|
||||||
|
---
|
||||||
|
|
||||||
|
{{< duplicate-oss >}}
|
|
@ -0,0 +1,16 @@
|
||||||
|
---
|
||||||
|
title: Line protocol reference
|
||||||
|
description: >
|
||||||
|
InfluxDB uses line protocol to write data points.
|
||||||
|
It is a text-based format that provides the measurement, tag set, field set, and timestamp of a data point.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Line protocol
|
||||||
|
parent: Other syntaxes
|
||||||
|
weight: 102
|
||||||
|
influxdb/cloud-dedicated/tags: [write, line protocol, syntax]
|
||||||
|
related:
|
||||||
|
- /influxdb/cloud-dedicated/write-data/
|
||||||
|
---
|
||||||
|
|
||||||
|
{{< duplicate-oss >}}
|
|
@ -0,0 +1,26 @@
|
||||||
|
---
|
||||||
|
title: Write data to InfluxDB Cloud Dedicated (Single-tenant)
|
||||||
|
list_title: Write data
|
||||||
|
description: >
|
||||||
|
Collect and write time series data to InfluxDB Cloud Dedicated.
|
||||||
|
weight: 3
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Write data
|
||||||
|
influxdb/cloud-dedicated/tags: [write, line protocol]
|
||||||
|
# related:
|
||||||
|
# - /influxdb/cloud/api/#tag/Write, InfluxDB API /write endpoint
|
||||||
|
# - /influxdb/cloud/reference/syntax/line-protocol
|
||||||
|
# - /influxdb/cloud/reference/syntax/annotated-csv
|
||||||
|
# - /influxdb/cloud/reference/cli/influx/write
|
||||||
|
# - /resources/videos/ingest-data/, How to Ingest Data in InfluxDB (Video)
|
||||||
|
---
|
||||||
|
|
||||||
|
Write data to {{% cloud-name %}} using the following tools and methods:
|
||||||
|
|
||||||
|
{{% warn %}}
|
||||||
|
{{% api/cloud/v2-prefer %}}
|
||||||
|
{{% /warn %}}
|
||||||
|
|
||||||
|
{{< children >}}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
---
|
||||||
|
title: Best practices for writing data
|
||||||
|
seotitle: Best practices for writing data to InfluxDB Cloud Dedicated
|
||||||
|
description: >
|
||||||
|
Learn about the recommendations and best practices for writing data to InfluxDB Cloud Dedicated.
|
||||||
|
weight: 105
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Best practices
|
||||||
|
identifier: write-best-practices
|
||||||
|
parent: Write data
|
||||||
|
---
|
||||||
|
|
||||||
|
The following articles walk through recommendations and best practices for writing
|
||||||
|
data to InfluxDB Cloud Dedicated.
|
||||||
|
|
||||||
|
{{< children >}}
|
|
@ -0,0 +1,376 @@
|
||||||
|
---
|
||||||
|
title: InfluxDB schema design recommendations
|
||||||
|
seotitle: InfluxDB schema design recommendations and best practices
|
||||||
|
description: >
|
||||||
|
Design your schema for simpler and more performant queries.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Schema design
|
||||||
|
weight: 201
|
||||||
|
parent: write-best-practices
|
||||||
|
---
|
||||||
|
|
||||||
|
Use the following guidelines to design your [schema](/influxdb/cloud-dedicated/reference/glossary/#schema)
|
||||||
|
for simpler and more performant queries.
|
||||||
|
|
||||||
|
<!-- TOC -->
|
||||||
|
|
||||||
|
- [InfluxDB data structure](#influxdb-data-structure)
|
||||||
|
- [Primary keys](#primary-keys)
|
||||||
|
- [Tags versus fields](#tags-versus-fields)
|
||||||
|
- [Schema restrictions](#schema-restrictions)
|
||||||
|
- [Do not use duplicate names for tags and fields](#do-not-use-duplicate-names-for-tags-and-fields)
|
||||||
|
- [Measurements can contain up to 200 columns](#measurements-can-contain-up-to-200-columns)
|
||||||
|
- [Design for performance](#design-for-performance)
|
||||||
|
- [Avoid wide schemas](#avoid-wide-schemas)
|
||||||
|
- [Avoid too many tags](#avoid-too-many-tags)
|
||||||
|
- [Avoid sparse schemas](#avoid-sparse-schemas)
|
||||||
|
- [Writing individual fields with different timestamps](#writing-individual-fields-with-different-timestamps)
|
||||||
|
- [Measurement schemas should be homogenous](#measurement-schemas-should-be-homogenous)
|
||||||
|
- [Design for query simplicity](#design-for-query-simplicity)
|
||||||
|
- [Keep measurement names, tag keys, and field keys simple](#keep-measurement-names-tag-keys-and-field-keys-simple)
|
||||||
|
- [Avoid keywords and special characters](#avoid-keywords-and-special-characters)
|
||||||
|
|
||||||
|
## InfluxDB data structure
|
||||||
|
|
||||||
|
The InfluxDB data model organizes time series data into buckets and measurements.
|
||||||
|
A bucket can contain multiple measurements. Measurements contain multiple
|
||||||
|
tags and fields.
|
||||||
|
|
||||||
|
- **Bucket**: Named location where time series data is stored.
|
||||||
|
In the InfluxDB SQL implementation, a bucket is synonymous with a _database_.
|
||||||
|
A bucket can contain multiple _measurements_.
|
||||||
|
- **Measurement**: Logical grouping for time series data.
|
||||||
|
In the InfluxDB SQL implementation, a measurement is synonymous with a _table_.
|
||||||
|
All _points_ in a given measurement should have the same _tags_.
|
||||||
|
A measurement contains multiple _tags_ and _fields_.
|
||||||
|
- **Tags**: Key-value pairs that store metadata string values for each point--for example,
|
||||||
|
a value that identifies or differentiates the data source or context--for example, host,
|
||||||
|
location, station, etc.
|
||||||
|
- **Fields**: Key-value pairs that store data for each point--for example,
|
||||||
|
temperature, pressure, stock price, etc.
|
||||||
|
- **Timestamp**: Timestamp associated with the data.
|
||||||
|
When stored on disk and queried, all data is ordered by time.
|
||||||
|
In InfluxDB, a timestamp is a nanosecond-scale [unix timestamp](#unix-timestamp) in UTC.
|
||||||
|
|
||||||
|
### Primary keys
|
||||||
|
|
||||||
|
In time series data, the primary key for a row of data is typically a combination of timestamp and other attributes that uniquely identify each data point.
|
||||||
|
In InfluxDB, the primary key for a row is the combination of the point's timestamp and _tag set_ - the collection of [tag keys](/influxdb/cloud-dedicated/reference/glossary/#tag-key) and [tag values](/influxdb/cloud-dedicated/reference/glossary/#tag-value) on the point.
|
||||||
|
|
||||||
|
### Tags versus fields
|
||||||
|
|
||||||
|
When designing your schema for InfluxDB, a common question is, "what should be a
|
||||||
|
tag and what should be a field?" The following guidelines should help answer that
|
||||||
|
question as you design your schema.
|
||||||
|
|
||||||
|
- Use tags to store identifying information about the source or context of the data.
|
||||||
|
- Use fields to store measured values.
|
||||||
|
- Tag values can only be strings.
|
||||||
|
- Field values can be any of the following data types:
|
||||||
|
- Integer
|
||||||
|
- Unsigned integer
|
||||||
|
- Float
|
||||||
|
- String
|
||||||
|
- Boolean
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
The InfluxDB IOx engine supports infinite tag value and series cardinality.
|
||||||
|
Unlike InfluxDB backed by the TSM storage engine, **tag value**
|
||||||
|
cardinality doesn't affect the overall performance of your database.
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Schema restrictions
|
||||||
|
|
||||||
|
### Do not use duplicate names for tags and fields
|
||||||
|
|
||||||
|
Tags and fields within the same measurement can't be named the same.
|
||||||
|
All tags and fields are stored as unique columns in a table representing the
|
||||||
|
measurement on disk.
|
||||||
|
If you attempt to write a measurement that contains tags or fields with the same name,
|
||||||
|
the write fails due to a column conflict.
|
||||||
|
|
||||||
|
### Measurements can contain up to 200 columns
|
||||||
|
|
||||||
|
A measurement can contain **up to 200 columns**. Each row requires a time column,
|
||||||
|
but the rest represent tags and fields stored in the measurement.
|
||||||
|
Therefore, a measurement can contain one time column and 199 total field and tag columns.
|
||||||
|
If you attempt to write to a measurement and exceed the 200 column limit, the
|
||||||
|
write request fails and InfluxDB returns an error.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Design for performance
|
||||||
|
|
||||||
|
How you structure your schema within a measurement can affect the overall
|
||||||
|
performance of queries against that measurement.
|
||||||
|
The following guidelines help to optimize query performance:
|
||||||
|
|
||||||
|
- [Avoid wide schemas](#avoid-wide-schemas)
|
||||||
|
- [Avoid sparse schemas](#avoid-sparse-schemas)
|
||||||
|
- [Measurement schemas should be homogenous](#measurement-schemas-should-be-homogenous)
|
||||||
|
|
||||||
|
|
||||||
|
### Avoid wide schemas
|
||||||
|
|
||||||
|
A wide schema is one with many tags and fields and corresponding columns for each.
|
||||||
|
With the InfluxDB IOx storage engine, wide schemas don't impact query execution performance.
|
||||||
|
Because IOx is a columnar database, it executes queries only against columns selected in the query.
|
||||||
|
|
||||||
|
Although a wide schema won't affect query performance, it can lead to the following:
|
||||||
|
|
||||||
|
- More resources required for persisting and compacting data during ingestion.
|
||||||
|
- Decreased sorting performance due to complex primary keys with [too many tags](#avoid-too-many-tags).
|
||||||
|
|
||||||
|
The InfluxDB IOx storage engine has a
|
||||||
|
[limit of 200 columns per measurement](#measurements-can-contain-up-to-200-columns).
|
||||||
|
|
||||||
|
To avoid a wide schema, limit the number of tags and fields stored in a measurement.
|
||||||
|
If you need to store more than 199 total tags and fields, consider segmenting
|
||||||
|
your fields into a separate measurement.
|
||||||
|
|
||||||
|
#### Avoid too many tags
|
||||||
|
|
||||||
|
In InfluxDB, the primary key for a row is the combination of the point's timestamp and _tag set_ - the collection of [tag keys](/influxdb/cloud-dedicated/reference/glossary/#tag-key) and [tag values](/influxdb/cloud-dedicated/reference/glossary/#tag-value) on the point.
|
||||||
|
A point that contains more tags has a more complex primary key, which could impact sorting performance if you sort using all parts of the key.
|
||||||
|
|
||||||
|
### Avoid sparse schemas
|
||||||
|
|
||||||
|
A sparse schema is one where, for many rows, columns contain null values.
|
||||||
|
|
||||||
|
These generally stem from the following:
|
||||||
|
- [non-homogenous measurement schemas](#measurement-schemas-should-be-homogenous)
|
||||||
|
- [writing individual fields with different timestamps](#writing-individual-fields-with-different-timestamps)
|
||||||
|
|
||||||
|
Sparse schemas require the InfluxDB query engine to evaluate many
|
||||||
|
null columns, adding unnecessary overhead to storing and querying data.
|
||||||
|
|
||||||
|
_For an example of a sparse schema,
|
||||||
|
[view the non-homogenous schema example below](#view-example-of-a-sparse-non-homogenous-schema)._
|
||||||
|
|
||||||
|
#### Writing individual fields with different timestamps
|
||||||
|
|
||||||
|
Reporting fields at different times with different timestamps creates distinct rows that contain null values--for example:
|
||||||
|
|
||||||
|
You report `fieldA` with `tagset`, and then report `field B` with the same `tagset`, but with a different timestamp.
|
||||||
|
The result is two rows: one row has a _null_ value for **field A** and the other has a _null_ value for **field B**.
|
||||||
|
|
||||||
|
In contrast, if you report fields at different times while using the same tagset and timestamp, the existing row is updated.
|
||||||
|
This requires slightly more resources at ingestion time, but then gets resolved at persistence time or compaction time
|
||||||
|
and avoids a sparse schema.
|
||||||
|
|
||||||
|
### Measurement schemas should be homogenous
|
||||||
|
|
||||||
|
Data stored within a measurement should be "homogenous," meaning each row should
|
||||||
|
have the same tag and field keys.
|
||||||
|
All rows stored in a measurement share the same columns, but if a point doesn't
|
||||||
|
include a value for a column, the column value is null.
|
||||||
|
A measurement full of null values has a ["sparse" schema](#avoid-sparse-schemas).
|
||||||
|
|
||||||
|
{{< expand-wrapper >}}
|
||||||
|
{{% expand "View example of a sparse, non-homogenous schema" %}}
|
||||||
|
|
||||||
|
Non-homogenous schemas are often caused by writing points to a measurement with
|
||||||
|
inconsistent tag or field sets.
|
||||||
|
In the following example, data is collected from two
|
||||||
|
different sources and each source returns data with different tag and field sets.
|
||||||
|
|
||||||
|
{{< flex >}}
|
||||||
|
{{% flex-content %}}
|
||||||
|
##### Source 1 tags and fields:
|
||||||
|
- tags:
|
||||||
|
- source
|
||||||
|
- code
|
||||||
|
- crypto
|
||||||
|
- fields:
|
||||||
|
- price
|
||||||
|
{{% /flex-content %}}
|
||||||
|
{{% flex-content %}}
|
||||||
|
##### Source 2 tags and fields:
|
||||||
|
- tags:
|
||||||
|
- src
|
||||||
|
- currency
|
||||||
|
- crypto
|
||||||
|
- fields:
|
||||||
|
- cost
|
||||||
|
- volume
|
||||||
|
{{% /flex-content %}}
|
||||||
|
{{< /flex >}}
|
||||||
|
|
||||||
|
These sets of data written to the same measurement will result in a measurement
|
||||||
|
full of null values (also known as a _sparse schema_):
|
||||||
|
|
||||||
|
| time | source | src | code | currency | crypto | price | cost | volume |
|
||||||
|
| :------------------- | :----- | --: | :--- | :------- | :------ | ----------: | ---------: | ----------: |
|
||||||
|
| 2023-01-01T12:00:00Z | src1 | | USD | | bitcoin | 16588.45865 | | |
|
||||||
|
| 2023-01-01T12:00:00Z | | 2 | | EUR | bitcoin | | 16159.5806 | 16749450200 |
|
||||||
|
| 2023-01-01T13:00:00Z | src1 | | USD | | bitcoin | 16559.49871 | | |
|
||||||
|
| 2023-01-01T13:00:00Z | | 2 | | EUR | bitcoin | | 16131.3694 | 16829683245 |
|
||||||
|
| 2023-01-01T14:00:00Z | src1 | | USD | | bitcoin | 16577.46667 | | |
|
||||||
|
| 2023-01-01T14:00:00Z | | 2 | | EUR | bitcoin | | 16148.8727 | 17151722208 |
|
||||||
|
| 2023-01-01T15:00:00Z | src1 | | USD | | bitcoin | 16591.36998 | | |
|
||||||
|
| 2023-01-01T15:00:00Z | | 2 | | EUR | bitcoin | | 16162.4167 | 17311854919 |
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
{{< /expand-wrapper >}}
|
||||||
|
|
||||||
|
## Design for query simplicity
|
||||||
|
|
||||||
|
Naming conventions for measurements, tag keys, and field keys can simplify or
|
||||||
|
complicate the process of writing queries for your data.
|
||||||
|
The following guidelines help to ensure writing queries for your data is as
|
||||||
|
simple as possible.
|
||||||
|
|
||||||
|
- [Keep measurement names, tag keys, and field keys simple](#keep-measurement-names-tag-keys-and-field-keys-simple)
|
||||||
|
- [Avoid keywords and special characters](#avoid-keywords-and-special-characters)
|
||||||
|
|
||||||
|
### Keep measurement names, tag keys, and field keys simple
|
||||||
|
|
||||||
|
Measurement names, tag keys, and field keys should be simple and accurately
|
||||||
|
describe what each contains.
|
||||||
|
|
||||||
|
The most common cause of a complex naming convention is when you try to "embed"
|
||||||
|
data attributes into a measurement name, tag key, or field key.
|
||||||
|
|
||||||
|
#### Not recommended {.orange}
|
||||||
|
|
||||||
|
As a basic example, consider the following [line protocol](/influxdb/cloud-dedicated/reference/syntax/line-protocol/)
|
||||||
|
that embeds sensor metadata (location, model, and ID) into a tag key:
|
||||||
|
|
||||||
|
```
|
||||||
|
home,sensor=loc-kitchen.model-A612.id-1726ZA temp=72.1
|
||||||
|
home,sensor=loc-bath.model-A612.id-2635YB temp=71.8
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< expand-wrapper >}}
|
||||||
|
{{% expand "View written data" %}}
|
||||||
|
|
||||||
|
{{% influxql/table-meta %}}
|
||||||
|
**name**: home
|
||||||
|
{{% /influxql/table-meta %}}
|
||||||
|
|
||||||
|
| time | sensor | temp |
|
||||||
|
| :------------------- | :------------------------------- | ---: |
|
||||||
|
| 2023-01-01T00:00:00Z | loc-kitchen.model-A612.id-1726ZA | 72.1 |
|
||||||
|
| 2023-01-01T00:00:00Z | loc-bath.model-A612.id-2635YB | 71.8 |
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
{{< /expand-wrapper >}}
|
||||||
|
|
||||||
|
To query data from the sensor with ID `1726ZA`, you have to use either SQL pattern
|
||||||
|
matching or regular expressions to evaluate the `sensor` tag:
|
||||||
|
|
||||||
|
{{< code-tabs-wrapper >}}
|
||||||
|
{{% code-tabs %}}
|
||||||
|
[SQL](#)
|
||||||
|
[InfluxQL](#)
|
||||||
|
[Flux](#)
|
||||||
|
{{% /code-tabs %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT * FROM home WHERE sensor LIKE '%id-1726ZA%'
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT * FROM home WHERE sensor =~ /id-1726ZA/
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
|
||||||
|
```js
|
||||||
|
import "experimental/iox"
|
||||||
|
|
||||||
|
iox.from(bucket: "example-bucket")
|
||||||
|
|> range(start: -1y)
|
||||||
|
|> filter(fn: (r) => r._measurement == "home")
|
||||||
|
|> filter(fn: (r) => r.sensor =~ /id-1726ZA/)
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{< /code-tabs-wrapper >}}
|
||||||
|
|
||||||
|
SQL pattern matching and regular expressions both complicate the query and
|
||||||
|
are less performant than simple equality expressions.
|
||||||
|
|
||||||
|
#### Recommended {.green}
|
||||||
|
|
||||||
|
The better approach would be to write each sensor attribute as an individual tag:
|
||||||
|
|
||||||
|
```
|
||||||
|
home,location=kitchen,sensor_model=A612,sensor_id=1726ZA temp=72.1
|
||||||
|
home,location=bath,sensor_model=A612,sensor_id=2635YB temp=71.8
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< expand-wrapper >}}
|
||||||
|
{{% expand "View written data" %}}
|
||||||
|
|
||||||
|
{{% influxql/table-meta %}}
|
||||||
|
**name**: home
|
||||||
|
{{% /influxql/table-meta %}}
|
||||||
|
|
||||||
|
| time | location | sensor_model | sensor_id | temp |
|
||||||
|
| :------------------- | :------- | :----------- | :-------- | ---: |
|
||||||
|
| 2023-01-01T00:00:00Z | kitchen | A612 | 1726ZA | 72.1 |
|
||||||
|
| 2023-01-01T00:00:00Z | bath | A612 | 2635YB | 71.8 |
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
{{< /expand-wrapper >}}
|
||||||
|
|
||||||
|
To query data from the sensor with ID `1726ZA` using this schema, you can use a
|
||||||
|
simple equality expression:
|
||||||
|
|
||||||
|
{{< code-tabs-wrapper >}}
|
||||||
|
{{% code-tabs %}}
|
||||||
|
[SQL & InfluxQL](#)
|
||||||
|
[Flux](#)
|
||||||
|
{{% /code-tabs %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT * FROM home WHERE sensor_id = '1726ZA'
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{% code-tab-content %}}
|
||||||
|
|
||||||
|
```js
|
||||||
|
import "experimental/iox"
|
||||||
|
|
||||||
|
iox.from(bucket: "example-bucket")
|
||||||
|
|> range(start: -1y)
|
||||||
|
|> filter(fn: (r) => r._measurement == "home")
|
||||||
|
|> filter(fn: (r) => r.sensor_id == "1726ZA")
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /code-tab-content %}}
|
||||||
|
{{< /code-tabs-wrapper >}}
|
||||||
|
|
||||||
|
This query is easier to write and is more performant than using pattern matching
|
||||||
|
or regular expressions.
|
||||||
|
|
||||||
|
### Avoid keywords and special characters
|
||||||
|
|
||||||
|
To simplify query writing, avoid using reserved keywords or special characters
|
||||||
|
in measurement names, tag keys, and field keys.
|
||||||
|
|
||||||
|
- [SQL keywords](/influxdb/cloud-dedicated/reference/sql/#keywords)
|
||||||
|
- [InfluxQL keywords](/influxdb/cloud-dedicated/reference/syntax/influxql/spec/#keywords)
|
||||||
|
|
||||||
|
When using SQL or InfluxQL to query measurements, tags, and fields with special
|
||||||
|
characters or keywords, you have to wrap these keys in **double quotes**.
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT
|
||||||
|
"example-field", "tag@1-23"
|
||||||
|
FROM
|
||||||
|
"example-measurement"
|
||||||
|
WHERE
|
||||||
|
"tag@1-23" = 'ABC'
|
||||||
|
```
|
|
@ -0,0 +1,18 @@
|
||||||
|
---
|
||||||
|
title: Write CSV data to InfluxDB Cloud Dedicated
|
||||||
|
description: >
|
||||||
|
Use Telegraf or the HTTP API to write CSV data
|
||||||
|
to InfluxDB Cloud Dedicated.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Write CSV data
|
||||||
|
parent: Write data
|
||||||
|
weight: 103
|
||||||
|
related:
|
||||||
|
- /influxdb/cloud-dedicated/reference/syntax/line-protocol/
|
||||||
|
- /influxdb/cloud-dedicated/reference/syntax/annotated-csv/
|
||||||
|
- /influxdb/cloud-dedicated/reference/cli/influx/write/
|
||||||
|
alt_engine: /influxdb/cloud/write-data/developer-tools/csv/
|
||||||
|
---
|
||||||
|
|
||||||
|
{{< children >}}
|
|
@ -0,0 +1,152 @@
|
||||||
|
---
|
||||||
|
title: Use Telegraf to write CSV data to InfluxDB Cloud Dedicated
|
||||||
|
description: >
|
||||||
|
Use the Telegraf `file` input plugin to read and parse CSV data into
|
||||||
|
[line protocol](/influxdb/cloud-dedicated/reference/syntax/line-protocol/)
|
||||||
|
and write it to InfluxDB.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Use Telegraf
|
||||||
|
identifier: write-csv-telegraf
|
||||||
|
parent: Write CSV data
|
||||||
|
weight: 203
|
||||||
|
related:
|
||||||
|
- /{{< latest "telegraf" >}}/data_formats/input/csv/
|
||||||
|
- /influxdb/cloud-dedicated/write-data/use-telegraf/
|
||||||
|
---
|
||||||
|
|
||||||
|
Use the Telegraf `file` input plugin to read and parse CSV data into
|
||||||
|
[line protocol](/influxdb/cloud-dedicated/reference/syntax/line-protocol/)
|
||||||
|
and write it to InfluxDB.
|
||||||
|
[Telegraf](/{{< latest "telegraf" >}}/) is a plugin-based agent that collects
|
||||||
|
metrics from different sources and writes them to specified destinations.
|
||||||
|
|
||||||
|
<!-- TOC -->
|
||||||
|
|
||||||
|
- [Configure Telegraf to read CSV files](#configure-telegraf-to-read-csv-files)
|
||||||
|
- [Configure Telegraf to write to InfluxDB](#configure-telegraf-to-write-to-influxdb)
|
||||||
|
- [Other Telegraf configuration options](#other-telegraf-configuration-options)
|
||||||
|
|
||||||
|
<!-- /TOC -->
|
||||||
|
|
||||||
|
## Configure Telegraf to read CSV files
|
||||||
|
|
||||||
|
1. Add and enable the [`inputs.file` plugin](/{{< latest "telegraf" >}}/plugins/#input-file)
|
||||||
|
in your Telegraf configuration file.
|
||||||
|
2. Use the `files` option to specify the list of CSV files to read.
|
||||||
|
CSV files must be accessible by the Telegraf agent.
|
||||||
|
3. Set the `data_format` option to `csv`.
|
||||||
|
4. Define all other `csv_` configuration options specific to the CSV data you
|
||||||
|
want to write to InfluxDB.
|
||||||
|
_For detailed information about each of the CSV format configuration options,
|
||||||
|
see [CSV input data format](/{{< latest "telegraf" >}}/data_formats/input/csv/)._
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[[inputs.file]]
|
||||||
|
files = ["/path/to/example.csv"]
|
||||||
|
data_format = "csv"
|
||||||
|
csv_header_row_count = 0
|
||||||
|
csv_column_names = []
|
||||||
|
csv_column_types = []
|
||||||
|
csv_skip_rows = 0
|
||||||
|
csv_metadata_rows = 0
|
||||||
|
csv_metadata_separators = [":", "="]
|
||||||
|
csv_metadata_trim_set = ""
|
||||||
|
csv_skip_columns = 0
|
||||||
|
csv_delimiter = ","
|
||||||
|
csv_comment = ""
|
||||||
|
csv_trim_space = false
|
||||||
|
csv_tag_columns = []
|
||||||
|
csv_measurement_column = ""
|
||||||
|
csv_timestamp_column = ""
|
||||||
|
csv_timestamp_format = ""
|
||||||
|
csv_timezone = ""
|
||||||
|
csv_skip_values = []
|
||||||
|
csv_skip_errors = false
|
||||||
|
csv_reset_mode = "none"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configure Telegraf to write to InfluxDB
|
||||||
|
|
||||||
|
1. Add and enable the [`outputs.influxdb_v2`](/{{< latest "telegraf" >}}/plugins/#output-influxdb_v2)
|
||||||
|
plugin in your Telegraf configuration file.
|
||||||
|
2. Include the following options:
|
||||||
|
|
||||||
|
- **url**: a list containing your Influx Cloud Dedicated cluster URL using the HTTPS
|
||||||
|
protocol:
|
||||||
|
|
||||||
|
```
|
||||||
|
https://cluster-id.influxdb.io
|
||||||
|
```
|
||||||
|
- **token**: a [database token](/influxdb/cloud-dedicated/admin/tokens/) with permission to write to the database.
|
||||||
|
- **organization**: an empty string (`''`) (InfluxDB Cloud Dedicated ignores this parameter).
|
||||||
|
- **bucket**: the name of the [database](/influxdb/cloud-dedicated/admin/databases/) to write to.
|
||||||
|
|
||||||
|
The following example shows a minimal [`outputs.influxdb_v2`](/{{< latest "telegraf" >}}/plugins/#output-influxdb_v2) configuration for writing data to InfluxDB Cloud Dedicated:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[[outputs.influxdb_v2]]
|
||||||
|
urls = ["https://cluster-id.influxdb.io"]
|
||||||
|
token = "DATABASE_TOKEN"
|
||||||
|
organization = ""
|
||||||
|
bucket = "DATABASE_NAME"
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace the following:
|
||||||
|
|
||||||
|
- **`DATABASE_NAME`**: your InfluxDB Cloud Dedicated database
|
||||||
|
- **`DATABASE_TOKEN`**: a [database token](/influxdb/cloud-dedicated/admin/tokens/) with sufficient permissions to the database
|
||||||
|
|
||||||
|
{{< expand-wrapper >}}
|
||||||
|
{{% expand "View full example Telegraf configuration file" %}}
|
||||||
|
|
||||||
|
In the following example:
|
||||||
|
|
||||||
|
- **`$INFLUX_TOKEN`** is an environment variable assigned to a [database token](/influxdb/cloud-dedicated/admin/tokens/) value.
|
||||||
|
- **`DATABASE_NAME`** is the InfluxDB Cloud Dedicated database to write to.
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[[inputs.file]]
|
||||||
|
files = ["/path/to/example.csv"]
|
||||||
|
data_format = "csv"
|
||||||
|
csv_header_row_count = 0
|
||||||
|
csv_column_names = []
|
||||||
|
csv_column_types = []
|
||||||
|
csv_skip_rows = 0
|
||||||
|
csv_metadata_rows = 0
|
||||||
|
csv_metadata_separators = [":", "="]
|
||||||
|
csv_metadata_trim_set = ""
|
||||||
|
csv_skip_columns = 0
|
||||||
|
csv_delimiter = ","
|
||||||
|
csv_comment = ""
|
||||||
|
csv_trim_space = false
|
||||||
|
csv_tag_columns = []
|
||||||
|
csv_measurement_column = ""
|
||||||
|
csv_timestamp_column = ""
|
||||||
|
csv_timestamp_format = ""
|
||||||
|
csv_timezone = ""
|
||||||
|
csv_skip_values = []
|
||||||
|
csv_skip_errors = false
|
||||||
|
csv_reset_mode = "none"
|
||||||
|
|
||||||
|
[[outputs.influxdb_v2]]
|
||||||
|
urls = ["https://cluster-id.influxdb.io"]
|
||||||
|
token = "$INFLUX_TOKEN"
|
||||||
|
organization = ""
|
||||||
|
bucket = "DATABASE_NAME"
|
||||||
|
content_encoding = "gzip"
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
{{< /expand-wrapper >}}
|
||||||
|
|
||||||
|
**Restart the Telegraf agent** to apply the configuration change and write the CSV
|
||||||
|
data to InfluxDB.
|
||||||
|
|
||||||
|
#### Other Telegraf configuration options
|
||||||
|
|
||||||
|
The preceding examples describe Telegraf configurations necessary for writing to InfluxDB Cloud Dedicated.
|
||||||
|
The output plugin provides several other options for configuring the Telegraf client:
|
||||||
|
|
||||||
|
- `influx_uint_support`: supported by the InfluxDB IOx storage engine.
|
||||||
|
- See [`influxdb_v2` plugin options](https://github.com/influxdata/telegraf/blob/master/plugins/outputs/influxdb_v2/README.md) on GitHub.
|
|
@ -0,0 +1,74 @@
|
||||||
|
---
|
||||||
|
title: Migrate data to InfluxDB Cloud Dedicated
|
||||||
|
description: >
|
||||||
|
Migrate data from InfluxDB powered by TSM (OSS, Enterprise, or Cloud) to
|
||||||
|
InfluxDB Cloud Dedicated.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Migrate data
|
||||||
|
parent: Write data
|
||||||
|
weight: 104
|
||||||
|
alt_engine: /influxdb/cloud/migrate-data/
|
||||||
|
---
|
||||||
|
|
||||||
|
Migrate data to InfluxDB Cloud Dedicated powered by InfluxDB IOx from other
|
||||||
|
InfluxDB instances powered by TSM including InfluxDB OSS 1.x, 2.x,
|
||||||
|
InfluxDB Enterprise, and InfluxDB Cloud (TSM).
|
||||||
|
|
||||||
|
- [Should you migrate?](#should-you-migrate)
|
||||||
|
- [Are you currently limited by series cardinality?](#are-you-currently-limited-by-series-cardinality)
|
||||||
|
- [Do you want to use SQL to query your data?](#do-you-want-to-use-sql-to-query-your-data)
|
||||||
|
- [Do you want better InfluxQL performance?](#do-you-want-better-influxql-performance)
|
||||||
|
- [Do you depend on a specific cloud provider or region?](#do-you-depend-on-a-specific-cloud-provider-or-region)
|
||||||
|
- [Are you reliant on Flux queries and Flux tasks?](#are-you-reliant-on-flux-queries-and-flux-tasks)
|
||||||
|
- [Data migration guides](#data-migration-guides)
|
||||||
|
|
||||||
|
## Should you migrate?
|
||||||
|
|
||||||
|
There are important things to consider with migrating to InfluxDB Cloud Dedicated.
|
||||||
|
The following questions will help guide your decision to migrate.
|
||||||
|
|
||||||
|
#### Are you currently limited by series cardinality?
|
||||||
|
|
||||||
|
**Yes, you should migrate**. Series cardinality is a major limiting factor with
|
||||||
|
the InfluxDB TSM storage engine. The more unique series in your data, the less
|
||||||
|
performant your database.
|
||||||
|
The IOx storage engine supports near limitless series cardinality and is, without
|
||||||
|
question, the better solution for high series cardinality workloads.
|
||||||
|
|
||||||
|
#### Do you want to use SQL to query your data?
|
||||||
|
|
||||||
|
**Yes, you should migrate**. InfluxDB Cloud Dedicated lets you query your time
|
||||||
|
series data with SQL. For more information about querying your data with SQL, see:
|
||||||
|
|
||||||
|
- [Query data with SQL](/influxdb/cloud-dedicated/query-data/sql/)
|
||||||
|
- [InfluxDB SQL reference](/influxdb/cloud-dedicated/reference/sql/)
|
||||||
|
|
||||||
|
#### Do you want better InfluxQL performance?
|
||||||
|
|
||||||
|
**Yes, you should migrate**. One of the primary goals when designing the InfluxDB
|
||||||
|
IOx storage engine was to enable performant implementations of both SQL and InfluxQL.
|
||||||
|
When compared to querying InfluxDB powered by TSM (InfluxDB OSS 1.x, 2.x, and Enterprise),
|
||||||
|
InfluxQL queries are more performant when querying InfluxDB powered by InfluxDB IOx.
|
||||||
|
|
||||||
|
#### Do you depend on a specific cloud provider or region?
|
||||||
|
|
||||||
|
**You should maybe migrate**. InfluxDB Cloud Dedicated instances are available
|
||||||
|
from the following providers:
|
||||||
|
|
||||||
|
{{< cloud_regions type=iox-list >}}
|
||||||
|
|
||||||
|
If your deployment requires other cloud providers or regions, you may need to
|
||||||
|
wait until the IOx storage engine is available in a region that meets your requirements.
|
||||||
|
We are currently working to make InfluxDB IOx available on more providers and
|
||||||
|
in more regions around the world.
|
||||||
|
|
||||||
|
#### Are you reliant on Flux queries and Flux tasks?
|
||||||
|
|
||||||
|
**You should not migrate**. InfluxDB Cloud Dedicated does not support Flux.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Data migration guides
|
||||||
|
|
||||||
|
{{< children >}}
|
|
@ -0,0 +1,238 @@
|
||||||
|
---
|
||||||
|
title: Migrate data from InfluxDB 1.x to InfluxDB Cloud Dedicated
|
||||||
|
description: >
|
||||||
|
To migrate data from a TSM-powered InfluxDB 1.x (OSS or Enterprise) to an
|
||||||
|
InfluxDB Cloud Dedicated cluster, export the data as line protocol and
|
||||||
|
write the exported data to your InfluxDB Cloud Dedicated database.
|
||||||
|
menu:
|
||||||
|
influxdb_cloud_dedicated:
|
||||||
|
name: Migrate from 1.x to Dedicated
|
||||||
|
parent: Migrate data
|
||||||
|
weight: 103
|
||||||
|
aliases:
|
||||||
|
- /influxdb/cloud-dedicated/write-data/migrate-data/migrate-1x-to-iox/
|
||||||
|
related:
|
||||||
|
- /influxdb/cloud-dedicated/admin/databases/
|
||||||
|
- /influxdb/cloud-dedicated/admin/tokens/
|
||||||
|
- /influxdb/cloud-dedicated/primers/api/v1/
|
||||||
|
- /influxdb/cloud-dedicated/primers/api/v2/
|
||||||
|
---
|
||||||
|
|
||||||
|
To migrate data from an InfluxDB 1.x OSS or Enterprise instance to InfluxDB Cloud
|
||||||
|
Dedicated, export the data as line protocol and write
|
||||||
|
the exported data to an InfluxDB Cloud Dedicated database.
|
||||||
|
|
||||||
|
## Tools to use
|
||||||
|
The migration process uses the following tools:
|
||||||
|
|
||||||
|
- **`influx_inspect` utility**:
|
||||||
|
The [`influx_inspect` utility](/{{< latest "influxdb" "v1" >}}/tools/influx_inspect/#export)
|
||||||
|
is packaged with InfluxDB 1.x OSS and Enterprise.
|
||||||
|
- **[`influxctl` admin CLI](/influxdb/cloud-dedicated/reference/cli/influxctl/)**.
|
||||||
|
- [v1 API `/write` endpoint](/influxdb/cloud-dedicated/primers/api/v1/) or [v2 API `/api/v2/write` endpoint](/influxdb/cloud-dedicated/primers/api/v2/) and API client libraries.
|
||||||
|
|
||||||
|
|
||||||
|
## Migrate data
|
||||||
|
|
||||||
|
1. **Export data from your InfluxDB 1.x instance as line protocol.**
|
||||||
|
|
||||||
|
Use the **InfluxDB 1.x `influx_inspect export` utility** to export data as
|
||||||
|
line protocol and store it in a file.
|
||||||
|
Include the following:
|
||||||
|
|
||||||
|
- ({{< req "Required" >}}) `-lponly` flag to export line protocol without InfluxQL DDL or DML.
|
||||||
|
- ({{< req "Required" >}}) `-out` flag with a path to an output file.
|
||||||
|
Default is `~/.influxdb/export`. _Any subsequent export commands without
|
||||||
|
the output file defined will overwrite the existing export file._
|
||||||
|
- `-compress` flag to use gzip to compress the output.
|
||||||
|
- `-datadir` flag with the path to your InfluxDB 1.x `data` directory.
|
||||||
|
Only required if the `data` directory is at a non-default location.
|
||||||
|
For information about default locations, see
|
||||||
|
[InfluxDB OSS 1.x file system layout](/{{< latest "influxdb" "v1" >}}/concepts/file-system-layout/#file-system-layout)
|
||||||
|
or [InfluxDB Enterprise 1.x file system layout](/{{< latest "enterprise_influxdb" >}}/concepts/file-system-layout/#file-system-layout).
|
||||||
|
- `-waldir` flag with the path to your InfluxDB 1.x `wal` directory.
|
||||||
|
Only required if the `wal` directory is at a non-default location.
|
||||||
|
For information about default locations, see
|
||||||
|
[InfluxDB OSS 1.x file system layout](/{{< latest "influxdb" "v1" >}}/concepts/file-system-layout/#file-system-layout)
|
||||||
|
or [InfluxDB Enterprise 1.x file system layout](/{{< latest "enterprise_influxdb" >}}/concepts/file-system-layout/#file-system-layout).
|
||||||
|
- `-database` flag with a specific database name to export.
|
||||||
|
By default, all databases are exported.
|
||||||
|
- `-retention` flag with a specific retention policy to export.
|
||||||
|
By default, all retention policies are exported.
|
||||||
|
- `-start` flag with an RFC3339 timestamp that defines the earliest time to export.
|
||||||
|
Default is `1677-09-20T16:27:54-07:44`.
|
||||||
|
- `-end` flag with an RFC3339 timestamp that defines the latest time to export.
|
||||||
|
Default is `2262-04-11T16:47:16-07:00`.
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
We recommend exporting each database and retention policy combination separately
|
||||||
|
to easily write the exported data into corresponding InfluxDB Cloud Dedicated
|
||||||
|
databases.
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
|
##### Export all data in a database and retention policy to a file
|
||||||
|
```sh
|
||||||
|
influx_inspect export \
|
||||||
|
-lponly \
|
||||||
|
-database example-db \
|
||||||
|
-retention example-rp \
|
||||||
|
-out path/to/export-file.lp
|
||||||
|
```
|
||||||
|
|
||||||
|
##### View more export command examples:
|
||||||
|
{{< expand-wrapper >}}
|
||||||
|
{{% expand "Export all data to a file" %}}
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influx_inspect export \
|
||||||
|
-lponly \
|
||||||
|
-out path/to/export-file.lp.gzip
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
|
||||||
|
{{% expand "Export all data to a compressed file" %}}
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influx_inspect export \
|
||||||
|
-lponly \
|
||||||
|
-compress \
|
||||||
|
-out path/to/export-file.lp.gzip
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
|
||||||
|
{{% expand "Export data within time bounds to a file" %}}
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influx_inspect export \
|
||||||
|
-lponly \
|
||||||
|
-start 2020-01-01T00:00:00Z \
|
||||||
|
-end 2023-01-01T00:00:00Z \
|
||||||
|
-out path/to/export-file.lp
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
|
||||||
|
{{% expand "Export a database and all its retention policies to a file" %}}
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influx_inspect export \
|
||||||
|
-lponly \
|
||||||
|
-database example-db \
|
||||||
|
-out path/to/export-file.lp
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
|
||||||
|
{{% expand "Export a specific database and retention policy to a file" %}}
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influx_inspect export \
|
||||||
|
-lponly \
|
||||||
|
-database example-db \
|
||||||
|
-retention example-rp \
|
||||||
|
-out path/to/export-file.lp
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
|
||||||
|
{{% expand "Export all data from _non-default_ `data` and `wal` directories" %}}
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influx_inspect export \
|
||||||
|
-lponly \
|
||||||
|
-datadir path/to/influxdb/data/ \
|
||||||
|
-waldir path/to/influxdb/wal/ \
|
||||||
|
-out path/to/export-file.lp
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
{{< /expand-wrapper >}}
|
||||||
|
|
||||||
|
2. Create InfluxDB Cloud Dedicated databases for each InfluxDB 1.x database and retention policy combination.
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
**If coming from InfluxDB v1**, the concepts of databases and retention policies
|
||||||
|
have been combined into a single concept--database. Retention policies are no
|
||||||
|
longer part of the InfluxDB data model. However, InfluxDB Cloud Dedicated does
|
||||||
|
support InfluxQL, which requires databases and retention policies.
|
||||||
|
See [InfluxQL DBRP naming convention](/influxdb/cloud-dedicated/admin/databases/create/#influxql-dbrp-naming-convention).
|
||||||
|
|
||||||
|
**If coming from InfluxDB v2 or InfluxDB Cloud**, _database_ and _bucket_ are synonymous.
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
|
{{< expand-wrapper >}}
|
||||||
|
{{% expand "View example 1.x databases and retention policies as InfluxDB Cloud Dedicated databases" %}}
|
||||||
|
If you have the following InfluxDB 1.x data structure:
|
||||||
|
|
||||||
|
- example-db <span style="opacity:.5;">_(database)_</span>
|
||||||
|
- autogen <span style="opacity:.5;">_(retention policy)_</span>
|
||||||
|
- historical-1mo <span style="opacity:.5;">_(retention policy)_</span>
|
||||||
|
- historical-6mo <span style="opacity:.5;">_(retention policy)_</span>
|
||||||
|
- historical-1y <span style="opacity:.5;">_(retention policy)_</span>
|
||||||
|
|
||||||
|
You would create the following InfluxDB {{< current-version >}} databases:
|
||||||
|
|
||||||
|
- example-db/autogen
|
||||||
|
- example-db/historical-1mo
|
||||||
|
- example-db/historical-6mo
|
||||||
|
- example-db/historical-1y
|
||||||
|
|
||||||
|
{{% /expand %}}
|
||||||
|
{{< /expand-wrapper >}}
|
||||||
|
|
||||||
|
Use the [`influxctl database create` command](/influxdb/cloud-dedicated/reference/cli/influxctl/database/create/)
|
||||||
|
to [create a database](/influxdb/cloud-dedicated/admin/databases/create/) in your InfluxDB Cloud Dedicated cluster.
|
||||||
|
|
||||||
|
Provide the following arguments:
|
||||||
|
|
||||||
|
- _(Optional)_ Database [retention period](/influxdb/cloud-dedicated/admin/databases/#retention-periods)
|
||||||
|
(default is infinite)
|
||||||
|
- Database name _(see [Database naming restrictions](#database-naming-restrictions))_
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl database create --retention-period 30d <DATABASE_NAME>
|
||||||
|
```
|
||||||
|
|
||||||
|
To learn more about databases in InfluxDB Cloud Dedicated, see [Manage databases](/influxdb/cloud-dedicated/admin/databases/).
|
||||||
|
|
||||||
|
3. **Create a database token for writing to your InfluxDB Cloud Dedicated database.**
|
||||||
|
|
||||||
|
Use the [`influxctl token create` command](/influxdb/cloud-dedicated/admin/tokens/create/)
|
||||||
|
to [create a database token](/influxdb/cloud-dedicated/admin/tokens/create/) with
|
||||||
|
_write_ permission to your database.
|
||||||
|
|
||||||
|
Provide the following:
|
||||||
|
|
||||||
|
- Permission grants
|
||||||
|
- `--read-database`: Grants read access to a database
|
||||||
|
- `--write-database` Grants write access to a database
|
||||||
|
- Token description
|
||||||
|
|
||||||
|
```sh
|
||||||
|
influxctl token create \
|
||||||
|
--read-database example-db \
|
||||||
|
--write-database example-db \
|
||||||
|
"Read/write token for example-db database"
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Write the exported line protocol to your InfluxDB Cloud Dedicated cluster.**
|
||||||
|
|
||||||
|
Use the v1 API or v2 API endpoints to write data to your InfluxDB Cloud Dedicated cluster.
|
||||||
|
|
||||||
|
Choose from the following options:
|
||||||
|
|
||||||
|
- The [v1 API `/write` endpoint](/influxdb/cloud-dedicated/primers/api/v1/) with v1 client libraries or HTTP clients.
|
||||||
|
- The [v2 API `/api/v2/write` endpoint](/influxdb/cloud-dedicated/primers/api/v2/) with v2 client libraries or HTTP clients.
|
||||||
|
|
||||||
|
Write each export file to the target database.
|
||||||
|
|
||||||
|
{{% warn %}}
|
||||||
|
#### v2.x influx CLI not supported
|
||||||
|
|
||||||
|
Don't use the `influx` CLI with InfluxDB Cloud Dedicated.
|
||||||
|
While it may coincidentally work, it isn't officially supported.
|
||||||
|
|
||||||
|
For help finding the best workflow for your situation, [contact Support](https://support.influxdata.com/).
|
||||||
|
{{% /warn %}}
|
|
@ -1,14 +0,0 @@
|
||||||
---
|
|
||||||
title: Manage your InfluxDB Cloud (IOx) Account
|
|
||||||
description: >
|
|
||||||
View and manage information related to your InfluxDB Cloud (IOx) account such as
|
|
||||||
pricing plans, data usage, account cancellation, etc.
|
|
||||||
weight: 10
|
|
||||||
menu:
|
|
||||||
influxdb_cloud_iox:
|
|
||||||
parent: Administer InfluxDB Cloud
|
|
||||||
name: Manage accounts
|
|
||||||
alt_engine: /influxdb/cloud/account-management/
|
|
||||||
---
|
|
||||||
|
|
||||||
{{< children >}}
|
|
|
@ -1,30 +0,0 @@
|
||||||
---
|
|
||||||
title: View InfluxDB Cloud (IOx) data usage
|
|
||||||
list_title: View data usage
|
|
||||||
description: >
|
|
||||||
View your InfluxDB Cloud (IOx) data usage and rate limit notifications.
|
|
||||||
weight: 103
|
|
||||||
menu:
|
|
||||||
influxdb_cloud_iox:
|
|
||||||
parent: Manage accounts
|
|
||||||
name: View data usage
|
|
||||||
related:
|
|
||||||
- /flux/v0.x/stdlib/experimental/usage/from/
|
|
||||||
- /flux/v0.x/stdlib/experimental/usage/limits/
|
|
||||||
alt_engine: /influxdb/cloud/account-management/data-usage/
|
|
||||||
---
|
|
||||||
|
|
||||||
View the statistics of your data usage and rate limits (reads, writes, and delete limits) on the InfluxDB Cloud UI **Usage** page. Some usage data affects monthly costs and other usage data (for example, delete limits), does not affect pricing. For more information, see [limits and adjustable quotas](/influxdb/cloud-iox/admin/accounts/limits/).
|
|
||||||
|
|
||||||
To view your {{< cloud-name >}} data usage, do the following:
|
|
||||||
|
|
||||||
1. Click on your organization in the header near the top of the page.
|
|
||||||
2. Select **Usage** from the dropdown menu.
|
|
||||||
3. Select a time range to review data usage (by default, `Past 24h`), and then select one of the following:
|
|
||||||
|
|
||||||
- **Data In:** Total data in MB written to your {{< cloud-name "short" >}} instance. Data in and write requests do not count towards your query count.
|
|
||||||
- **Query Count:** Total number of individual query operations, which include queries, tasks (alerts, notifications) and Data Explorer activity. Note, a script that includes multiple requests (for example, has multiple `from()...` lines) counts as one query.
|
|
||||||
- **Storage:** Total disk usage in gigabytes.
|
|
||||||
- **Data Out:** Total data in MB sent as responses to queries from your {{< cloud-name "short" >}} instance.
|
|
||||||
|
|
||||||
A line graph displays usage for the selected vector for the specified time period.
|
|
|
@ -1,12 +0,0 @@
|
||||||
---
|
|
||||||
title: InfluxDB Cloud reference documentation
|
|
||||||
description: >
|
|
||||||
Reference documentation for InfluxDB Cloud including updates, API documentation,
|
|
||||||
tools, syntaxes, and more.
|
|
||||||
menu:
|
|
||||||
influxdb_cloud_iox:
|
|
||||||
name: Reference
|
|
||||||
weight: 20
|
|
||||||
---
|
|
||||||
|
|
||||||
{{< children >}}
|
|
|
@ -1,26 +0,0 @@
|
||||||
---
|
|
||||||
title: influx apply
|
|
||||||
description: The `influx apply` command applies InfluxDB templates.
|
|
||||||
menu:
|
|
||||||
influxdb_cloud_iox:
|
|
||||||
name: influx apply
|
|
||||||
parent: influx
|
|
||||||
weight: 101
|
|
||||||
aliases:
|
|
||||||
- /influxdb/cloud-iox/reference/cli/influx/pkg/
|
|
||||||
influxdb/cloud-iox/tags: [templates]
|
|
||||||
related:
|
|
||||||
- /influxdb/cloud-iox/reference/cli/influx/#provide-required-authentication-credentials, influx CLI—Provide required authentication credentials
|
|
||||||
- /influxdb/cloud-iox/reference/cli/influx/#flag-patterns-and-conventions, influx CLI—Flag patterns and conventions
|
|
||||||
metadata: [influx CLI 2.0.0+]
|
|
||||||
---
|
|
||||||
|
|
||||||
{{% warn %}}
|
|
||||||
#### Not supported in InfluxDB IOx-powered organizations
|
|
||||||
|
|
||||||
While this command is included in the `influx` CLI {{< latest-cli >}}, this
|
|
||||||
functionality is not available in InfluxDB Cloud organizations powered by the
|
|
||||||
InfluxDB IOx storage engine.
|
|
||||||
{{% /warn %}}
|
|
||||||
|
|
||||||
{{< duplicate-oss >}}
|
|
|
@ -1,17 +0,0 @@
|
||||||
---
|
|
||||||
title: influx auth
|
|
||||||
description: The `influx auth` command and its subcommands manage API tokens in InfluxDB.
|
|
||||||
menu:
|
|
||||||
influxdb_cloud_iox:
|
|
||||||
name: influx auth
|
|
||||||
parent: influx
|
|
||||||
weight: 101
|
|
||||||
influxdb/cloud-iox/tags: [authentication]
|
|
||||||
cascade:
|
|
||||||
related:
|
|
||||||
- /influxdb/cloud-iox/reference/cli/influx/#provide-required-authentication-credentials, influx CLI—Provide required authentication credentials
|
|
||||||
- /influxdb/cloud-iox/reference/cli/influx/#flag-patterns-and-conventions, influx CLI—Flag patterns and conventions
|
|
||||||
metadata: [influx CLI 2.0.0+]
|
|
||||||
---
|
|
||||||
|
|
||||||
{{< duplicate-oss >}}
|
|
|
@ -1,19 +0,0 @@
|
||||||
---
|
|
||||||
title: influx bucket-schema
|
|
||||||
description: The `influx bucket-schema` command and its subcommands manage schemas of buckets in InfluxDB.
|
|
||||||
menu:
|
|
||||||
influxdb_cloud_iox:
|
|
||||||
name: influx bucket-schema
|
|
||||||
parent: influx
|
|
||||||
weight: 101
|
|
||||||
influxdb/cloud-iox/tags: [buckets, bucket-schema]
|
|
||||||
cascade:
|
|
||||||
related:
|
|
||||||
- /influxdb/cloud/organizations/buckets/bucket-schema
|
|
||||||
- /influxdb/cloud/organizations/buckets/
|
|
||||||
- /influxdb/cloud-iox/reference/cli/influx/#provide-required-authentication-credentials, influx CLI—Provide required authentication credentials
|
|
||||||
- /influxdb/cloud-iox/reference/cli/influx/#provide-required-authentication-credentials, influx CLI—Provide required authentication credentials
|
|
||||||
metadata: [influx CLI 2.1.0+]
|
|
||||||
---
|
|
||||||
|
|
||||||
{{< duplicate-oss >}}
|
|
|
@ -1,18 +0,0 @@
|
||||||
---
|
|
||||||
title: influx bucket
|
|
||||||
description: The `influx bucket` command and its subcommands manage buckets in InfluxDB.
|
|
||||||
menu:
|
|
||||||
influxdb_cloud_iox:
|
|
||||||
name: influx bucket
|
|
||||||
parent: influx
|
|
||||||
weight: 101
|
|
||||||
influxdb/cloud-iox/tags: [buckets]
|
|
||||||
cascade:
|
|
||||||
related:
|
|
||||||
- /influxdb/cloud-iox/organizations/buckets/
|
|
||||||
- /influxdb/cloud-iox/reference/cli/influx/#provide-required-authentication-credentials, influx CLI—Provide required authentication credentials
|
|
||||||
- /influxdb/cloud-iox/reference/cli/influx/#flag-patterns-and-conventions, influx CLI—Flag patterns and conventions
|
|
||||||
metadata: [influx CLI 2.0.0+]
|
|
||||||
---
|
|
||||||
|
|
||||||
{{< duplicate-oss >}}
|
|
|
@ -1,15 +0,0 @@
|
||||||
---
|
|
||||||
title: influx bucket delete
|
|
||||||
description: The `influx bucket delete` command deletes a bucket from InfluxDB and all the data it contains.
|
|
||||||
menu:
|
|
||||||
influxdb_cloud_iox:
|
|
||||||
name: influx bucket delete
|
|
||||||
parent: influx bucket
|
|
||||||
weight: 201
|
|
||||||
related:
|
|
||||||
- /influxdb/cloud/organizations/buckets/delete-bucket/
|
|
||||||
- /influxdb/cloud-iox/reference/cli/influx/#provide-required-authentication-credentials, influx CLI—Provide required authentication credentials
|
|
||||||
- /influxdb/cloud-iox/reference/cli/influx/#provide-required-authentication-credentials, influx CLI—Provide required authentication credentials
|
|
||||||
---
|
|
||||||
|
|
||||||
{{< duplicate-oss >}}
|
|
|
@ -1,18 +0,0 @@
|
||||||
---
|
|
||||||
title: influx completion
|
|
||||||
description: >
|
|
||||||
The `influx completion` command outputs `influx` shell completion scripts for a
|
|
||||||
specified shell (`bash` or `zsh`).
|
|
||||||
menu:
|
|
||||||
influxdb_cloud_iox:
|
|
||||||
name: influx completion
|
|
||||||
parent: influx
|
|
||||||
weight: 101
|
|
||||||
influxdb/cloud-iox/tags: [cli, tools]
|
|
||||||
related:
|
|
||||||
- /influxdb/cloud-iox/reference/cli/influx/#provide-required-authentication-credentials, influx CLI—Provide required authentication credentials
|
|
||||||
- /influxdb/cloud-iox/reference/cli/influx/#provide-required-authentication-credentials, influx CLI—Provide required authentication credentials
|
|
||||||
metadata: [influx CLI 2.0.0+]
|
|
||||||
---
|
|
||||||
|
|
||||||
{{< duplicate-oss >}}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue