Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 62 additions & 31 deletions assets/js/influxdb-version-detector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,24 @@ class InfluxDBVersionDetector {
private restartBtn: HTMLElement | null = null;
private currentContext: 'questionnaire' | 'result' = 'questionnaire';

/** Example host URLs for each product type */
private static readonly HOST_EXAMPLES: Record<string, string> = {
influxdb3_core: 'http://localhost:8181',
influxdb3_enterprise: 'http://localhost:8181',
influxdb3_cloud_serverless: 'https://cloud2.influxdata.com',
influxdb3_cloud_dedicated: 'https://cluster-id.a.influxdb.io',
influxdb3_clustered: 'https://cluster-host.com',
influxdb_v1: 'http://localhost:8086',
influxdb_v2: 'http://localhost:8086',
};

/** Default host URL (InfluxDB v2 localhost) */
private static readonly DEFAULT_HOST =
InfluxDBVersionDetector.HOST_EXAMPLES.influxdb_v2;

/** Default host:port without protocol (for curl examples) */
private static readonly DEFAULT_HOST_PORT = 'localhost:8086';

constructor(options: ComponentOptions) {
this.container = options.component;

Expand Down Expand Up @@ -627,17 +645,10 @@ class InfluxDBVersionDetector {
}

// Fallback based on product type
const hostExamples: Record<string, string> = {
influxdb3_core: 'http://localhost:8181',
influxdb3_enterprise: 'http://localhost:8181',
influxdb3_cloud_serverless: 'https://cloud2.influxdata.com',
influxdb3_cloud_dedicated: 'https://cluster-id.a.influxdb.io',
influxdb3_clustered: 'https://cluster-host.com',
influxdb_v1: 'http://localhost:8086',
influxdb_v2: 'http://localhost:8086',
};

return hostExamples[productDataKey] || 'http://localhost:8086';
return (
InfluxDBVersionDetector.HOST_EXAMPLES[productDataKey] ||
InfluxDBVersionDetector.DEFAULT_HOST
);
}

private usesDatabaseTerminology(productConfig: ProductConfig): boolean {
Expand Down Expand Up @@ -888,7 +899,7 @@ class InfluxDBVersionDetector {
</div>
<div class="input-group">
<input type="url" id="url-input"
placeholder="for example, https://us-east-1-1.aws.cloud2.influxdata.com or http://localhost:8086">
placeholder="for example, https://us-east-1-1.aws.cloud2.influxdata.com or ${InfluxDBVersionDetector.DEFAULT_HOST}">
</div>
<button class="back-button" data-action="go-back">Back</button>
<button class="submit-button"
Expand Down Expand Up @@ -930,7 +941,7 @@ class InfluxDBVersionDetector {
docker exec &lt;container&gt; influxd version

# Get ping headers:
docker exec &lt;container&gt; curl -I localhost:8086/ping
docker exec &lt;container&gt; curl -I ${InfluxDBVersionDetector.DEFAULT_HOST_PORT}/ping

# Or check startup logs:
docker logs &lt;container&gt; 2>&amp;1 | head -20</div>
Expand Down Expand Up @@ -1207,7 +1218,7 @@ docker logs &lt;container&gt; 2>&amp;1 | head -20</div>
const currentProduct = this.getCurrentProduct();
const storedUrl = storedUrls[currentProduct] || storedUrls.custom;

if (storedUrl && storedUrl !== 'http://localhost:8086') {
if (storedUrl && storedUrl !== InfluxDBVersionDetector.DEFAULT_HOST) {
urlInput.value = storedUrl;
// Add indicator that URL was pre-filled (only if one doesn't already exist)
const existingIndicator = urlInput.parentElement?.querySelector(
Expand Down Expand Up @@ -1491,29 +1502,49 @@ docker logs &lt;container&gt; 2>&amp;1 | head -20</div>
licenseGuidance.style.borderRadius = '4px';

if (answer === 'free') {
const freeProducts = [
'InfluxDB 3 Core',
'InfluxDB OSS 2.x',
'InfluxDB OSS 1.x',
];
const freeLinks = freeProducts
.map((product) => {
const link = this.getGrafanaLink(product);
return link
? `<li><a href="${link}" target="_blank" class="grafana-link">Configure Grafana for ${product}</a></li>`
: '';
})
.filter(Boolean)
.join('\n ');

licenseGuidance.innerHTML = `
<strong>Free/Open Source License:</strong>
<p>This suggests you're using InfluxDB 3 Core or InfluxDB OSS.</p>
<ul>
<li><a href="/influxdb3/core/visualize-data/grafana/"
target="_blank" class="grafana-link">Configure Grafana for InfluxDB 3 Core</a></li>
<li><a href="/influxdb/v2/visualize-data/grafana/"
target="_blank" class="grafana-link">Configure Grafana for InfluxDB OSS v2</a></li>
<li><a href="/influxdb/v1/tools/grafana/"
target="_blank" class="grafana-link">Configure Grafana for InfluxDB OSS v1</a></li>
${freeLinks}
</ul>
`;
} else if (answer === 'paid') {
const paidProducts = [
'InfluxDB 3 Enterprise',
'InfluxDB Cloud Dedicated',
'InfluxDB Cloud Serverless',
];
const paidLinks = paidProducts
.map((product) => {
const link = this.getGrafanaLink(product);
return link
? `<li><a href="${link}" target="_blank" class="grafana-link">Configure Grafana for ${product}</a></li>`
: '';
})
.filter(Boolean)
.join('\n ');

licenseGuidance.innerHTML = `
<strong>Paid/Commercial License:</strong>
<p>This suggests you're using InfluxDB 3 Enterprise or a paid cloud service.</p>
<ul>
<li><a href="/influxdb3/enterprise/visualize-data/grafana/"
target="_blank" class="grafana-link">Configure Grafana for InfluxDB 3 Enterprise</a></li>
<li><a href="/influxdb3/cloud-dedicated/visualize-data/grafana/"
target="_blank" class="grafana-link">Configure Grafana for InfluxDB Cloud Dedicated</a></li>
<li><a href="/influxdb3/cloud-serverless/visualize-data/grafana/"
target="_blank" class="grafana-link">Configure Grafana for InfluxDB Cloud Serverless</a></li>
${paidLinks}
</ul>
`;
}
Expand Down Expand Up @@ -1581,11 +1612,11 @@ docker logs &lt;container&gt; 2>&amp;1 | head -20</div>
'InfluxDB Cloud Serverless':
'/influxdb3/cloud-serverless/visualize-data/grafana/',
'InfluxDB OSS 1.x': '/influxdb/v1/tools/grafana/',
'InfluxDB OSS 2.x': '/influxdb/v2/visualize-data/grafana/',
'InfluxDB Enterprise': '/influxdb/enterprise/visualize-data/grafana/',
'InfluxDB OSS 2.x': '/influxdb/v2/tools/grafana/',
'InfluxDB Enterprise': '/enterprise_influxdb/v1/tools/grafana/',
'InfluxDB Clustered': '/influxdb3/clustered/visualize-data/grafana/',
'InfluxDB Cloud (TSM)': '/influxdb/cloud/visualize-data/grafana/',
'InfluxDB Cloud v1': '/influxdb/cloud/visualize-data/grafana/',
'InfluxDB Cloud (TSM)': '/influxdb/cloud/tools/grafana/',
'InfluxDB Cloud v1': '/enterprise_influxdb/v1/tools/grafana/',
};

return GRAFANA_LINKS[productName] || null;
Expand Down Expand Up @@ -2275,7 +2306,7 @@ curl -I ${url}/ping
docker exec &lt;container&gt; influxd version

# Get ping headers:
docker exec &lt;container&gt; curl -I localhost:8086/ping
docker exec &lt;container&gt; curl -I ${InfluxDBVersionDetector.DEFAULT_HOST_PORT}/ping

# Or check startup logs:
docker logs &lt;container&gt; 2>&1 | head -20
Expand Down
Loading