diff --git a/.circleci/config.yml b/.circleci/config.yml index 351292b8..39431675 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -59,6 +59,8 @@ jobs: PIPENV_VENV_IN_PROJECT: true ENABLED_CISO_8601: << parameters.enabled-ciso-8601 >> - image: quay.io/influxdb/<< parameters.influxdb-image >> + environment: + INFLUXD_HTTP_BIND_ADDRESS: :8086 steps: - prepare - client-test: diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c2ca227..154678e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## 1.11.0 [unreleased] +### API + 1. [#151](https://github.com/influxdata/influxdb-client-python/pull/151): Default port changed from 9999 -> 8086 + ## 1.10.0 [2020-08-14] ### Features diff --git a/README.rst b/README.rst index 77aac9bb..7ff0a5a8 100644 --- a/README.rst +++ b/README.rst @@ -128,7 +128,7 @@ Please follow the `Installation`_ and then run the following: bucket = "my-bucket" - client = InfluxDBClient(url="http://localhost:9999", token="my-token", org="my-org") + client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org") write_api = client.write_api(write_options=SYNCHRONOUS) query_api = client.query_api() @@ -178,7 +178,7 @@ The following options are supported: .. code-block:: [influx2] - url=http://localhost:9999 + url=http://localhost:8086 org=my-org token=my-token timeout=6000 @@ -270,7 +270,7 @@ The batching is configurable by ``write_options``\ : from influxdb_client import InfluxDBClient, Point, WriteOptions from influxdb_client.client.write_api import SYNCHRONOUS - _client = InfluxDBClient(url="http://localhost:9999", token="my-token", org="my-org") + _client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org") _write_client = _client.write_api(write_options=WriteOptions(batch_size=500, flush_interval=10_000, jitter_interval=2_000, @@ -380,7 +380,7 @@ In a ini configuration file you are able to specify default tags by ``tags`` seg .. code-block:: [influx2] - url=http://localhost:9999 + url=http://localhost:8086 org=my-org token=my-token timeout=6000 @@ -415,7 +415,7 @@ Data are writes in an asynchronous HTTP request. from influxdb_client import InfluxDBClient, Point from influxdb_client.client.write_api import ASYNCHRONOUS - client = InfluxDBClient(url="http://localhost:9999", token="my-token", org="my-org") + client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org") write_api = client.write_api(write_options=ASYNCHRONOUS) _point1 = Point("my_measurement").tag("location", "Prague").field("temperature", 25.3) @@ -436,7 +436,7 @@ Data are writes in a synchronous HTTP request. from influxdb_client import InfluxDBClient, Point from influxdb_client .client.write_api import SYNCHRONOUS - client = InfluxDBClient(url="http://localhost:9999", token="my-token", org="my-org") + client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org") write_api = client.write_api(write_options=SYNCHRONOUS) _point1 = Point("my_measurement").tag("location", "Prague").field("temperature", 25.3) @@ -463,7 +463,7 @@ The API also support streaming ``FluxRecord`` via `query_stream rename(columns: {_time: "pickup_datetime"})' \ '|> drop(columns: ["_start", "_stop"])|> limit(n:10, offset: 0)' -client = InfluxDBClient(url="http://localhost:9999", token="my-token", org="my-org", debug=False) +client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org", debug=False) result = client.query_api().query(query=query) """ diff --git a/examples/ingest_dataframe_default_tags.py b/examples/ingest_dataframe_default_tags.py index 4460e0c3..4e9afd3d 100644 --- a/examples/ingest_dataframe_default_tags.py +++ b/examples/ingest_dataframe_default_tags.py @@ -13,7 +13,7 @@ df = pd.read_csv("vix-daily.csv") print(df.head()) -client = InfluxDBClient(url="http://localhost:9999", token="my-token", org="my-org") +client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org") """ Ingest DataFrame with default tags diff --git a/examples/iot_sensor.py b/examples/iot_sensor.py index c526a753..02c1c79c 100644 --- a/examples/iot_sensor.py +++ b/examples/iot_sensor.py @@ -61,7 +61,7 @@ def line_protocol(temperature): ops.distinct_until_changed(), ops.map(lambda temperature: line_protocol(temperature))) -_db_client = InfluxDBClient(url="http://localhost:9999", token="my-token", org="my-org", debug=True) +_db_client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org", debug=True) """ Create client that writes data into InfluxDB diff --git a/examples/nanosecond_precision.py b/examples/nanosecond_precision.py index e242d282..223aa68d 100644 --- a/examples/nanosecond_precision.py +++ b/examples/nanosecond_precision.py @@ -12,7 +12,7 @@ """ Prepare client. """ -client = InfluxDBClient(url="http://localhost:9999", token="my-token", org="my-org") +client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org") write_api = client.write_api(write_options=SYNCHRONOUS) query_api = client.query_api() diff --git a/examples/query.py b/examples/query.py index 85d55a1a..91581d06 100644 --- a/examples/query.py +++ b/examples/query.py @@ -1,7 +1,7 @@ from influxdb_client import InfluxDBClient, Point, Dialect from influxdb_client.client.write_api import SYNCHRONOUS -client = InfluxDBClient(url="http://localhost:9999", token="my-token", org="my-org") +client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org") write_api = client.write_api(write_options=SYNCHRONOUS) query_api = client.query_api() diff --git a/examples/query_from_file.py b/examples/query_from_file.py index c0e7b54d..f98c887c 100644 --- a/examples/query_from_file.py +++ b/examples/query_from_file.py @@ -10,7 +10,7 @@ from influxdb_client import InfluxDBClient, Point from influxdb_client.client.write_api import SYNCHRONOUS -client = InfluxDBClient(url="http://localhost:9999", token="my-token", org="my-org") +client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org") write_api = client.write_api(write_options=SYNCHRONOUS) query_api = client.query_api() diff --git a/influxdb_client/client/influxdb_client.py b/influxdb_client/client/influxdb_client.py index a791513e..deab2cab 100644 --- a/influxdb_client/client/influxdb_client.py +++ b/influxdb_client/client/influxdb_client.py @@ -25,7 +25,7 @@ def __init__(self, url, token, debug=None, timeout=10000, enable_gzip=False, org """ Initialize defaults. - :param url: InfluxDB server API url (ex. http://localhost:9999). + :param url: InfluxDB server API url (ex. http://localhost:8086). :param token: auth token :param debug: enable verbose logging of http requests :param timeout: default http client timeout @@ -118,7 +118,7 @@ def from_env_properties(cls, debug=None, enable_gzip=False): - INFLUXDB_V2_TIMEOUT - INFLUXDB_V2_VERIFY_SSL """ - url = os.getenv('INFLUXDB_V2_URL', "http://localhost:9999") + url = os.getenv('INFLUXDB_V2_URL', "http://localhost:8086") token = os.getenv('INFLUXDB_V2_TOKEN', "my-token") timeout = os.getenv('INFLUXDB_V2_TIMEOUT', "10000") org = os.getenv('INFLUXDB_V2_ORG', "my-org") diff --git a/notebooks/realtime-stream.ipynb b/notebooks/realtime-stream.ipynb index e65705a9..1889f249 100644 --- a/notebooks/realtime-stream.ipynb +++ b/notebooks/realtime-stream.ipynb @@ -71,7 +71,7 @@ "metadata": {}, "outputs": [], "source": [ - "client = InfluxDBClient(url='http://localhost:9999', token='my-token', org='my-org')" + "client = InfluxDBClient(url='http://localhost:8086', token='my-token', org='my-org')" ] }, { diff --git a/notebooks/stock-predictions.ipynb b/notebooks/stock-predictions.ipynb index 6a28f0fd..d94c1bb8 100644 --- a/notebooks/stock-predictions.ipynb +++ b/notebooks/stock-predictions.ipynb @@ -103,7 +103,7 @@ "#prices_dataset = pd.read_csv('./prices-split-adjusted.csv', header=0)\n", "\n", "# read prices from InfluxDB 2.0 \n", - "client = InfluxDBClient(url=\"http://localhost:9999\", token=\"my-token\", org=\"my-org\", debug=False)\n", + "client = InfluxDBClient(url=\"http://localhost:8086\", token=\"my-token\", org=\"my-org\", debug=False)\n", "query='''\n", "from(bucket:\"my-bucket\")\n", " |> range(start: 0, stop: now())\n", diff --git a/notebooks/stock_predictions_import_data.py b/notebooks/stock_predictions_import_data.py index df6befea..93996dc4 100644 --- a/notebooks/stock_predictions_import_data.py +++ b/notebooks/stock_predictions_import_data.py @@ -57,7 +57,7 @@ def main(): .from_iterable(DictReader(response.iter_lines(decode_unicode=True))) \ .pipe(ops.map(lambda row: parse_row(row))) - client = InfluxDBClient(url="http://localhost:9999", token="my-token", org="my-org", debug=False) + client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org", debug=False) write_api = client.write_api(write_options=WriteOptions(batch_size=50_000, flush_interval=10_000)) write_api.write(bucket="my-bucket", record=data) diff --git a/notebooks/telegraf.conf b/notebooks/telegraf.conf index 64978115..35bc54c0 100644 --- a/notebooks/telegraf.conf +++ b/notebooks/telegraf.conf @@ -93,7 +93,7 @@ ## ## Multiple URLs can be specified for a single cluster, only ONE of the ## urls will be written to each interval. - urls = ["http://localhost:9999/"] + urls = ["http://localhost:8086/"] ## Token for authentication. token = "my-token" diff --git a/scripts/influxdb-onboarding.sh b/scripts/influxdb-onboarding.sh index 4bbf3f00..85da2272 100755 --- a/scripts/influxdb-onboarding.sh +++ b/scripts/influxdb-onboarding.sh @@ -24,12 +24,12 @@ set -e echo "Wait to start InfluxDB 2.0" -wget -S --spider --tries=20 --retry-connrefused --waitretry=5 http://localhost:9999/metrics +wget -S --spider --tries=20 --retry-connrefused --waitretry=5 http://localhost:8086/metrics echo echo "Post onBoarding request, to setup initial user (my-user@my-password), org (my-org) and bucketSetup (my-bucket)" echo -curl -i -X POST http://localhost:9999/api/v2/setup -H 'accept: application/json' \ +curl -i -X POST http://localhost:8086/api/v2/setup -H 'accept: application/json' \ -d '{ "username": "my-user", "password": "my-password", diff --git a/scripts/influxdb-restart.sh b/scripts/influxdb-restart.sh index 480b8f09..434a2e59 100755 --- a/scripts/influxdb-restart.sh +++ b/scripts/influxdb-restart.sh @@ -49,13 +49,14 @@ echo docker pull ${INFLUXDB_V2_IMAGE} || true docker run \ --detach \ + --env INFLUXD_HTTP_BIND_ADDRESS=:8086 \ --name influxdb_v2 \ --network influx_network \ - --publish 9999:9999 \ + --publish 8086:8086 \ ${INFLUXDB_V2_IMAGE} echo "Wait to start InfluxDB 2.0" -wget -S --spider --tries=20 --retry-connrefused --waitretry=5 http://localhost:9999/metrics +wget -S --spider --tries=20 --retry-connrefused --waitretry=5 http://localhost:8086/metrics # # Post onBoarding request to InfluxDB 2 diff --git a/tests/base_test.py b/tests/base_test.py index 37737a7e..a2db8140 100644 --- a/tests/base_test.py +++ b/tests/base_test.py @@ -19,7 +19,7 @@ class BaseTest(unittest.TestCase): def setUp(self) -> None: self.conf = influxdb_client.configuration.Configuration() - self.host = os.getenv('INFLUXDB_V2_URL', "http://localhost:9999") + self.host = os.getenv('INFLUXDB_V2_URL', "http://localhost:8086") self.debug = False self.auth_token = os.getenv('INFLUXDB_V2_TOKEN', "my-token") self.org = os.getenv('INFLUXDB_V2_ORG', "my-org") diff --git a/tests/config-disabled-ssl.ini b/tests/config-disabled-ssl.ini index 72215b66..0a1aba25 100644 --- a/tests/config-disabled-ssl.ini +++ b/tests/config-disabled-ssl.ini @@ -1,5 +1,5 @@ [influx2] -url=http://localhost:9999 +url=http://localhost:8086 org=my-org token=my-token timeout=6000 diff --git a/tests/config.ini b/tests/config.ini index 02e24397..8b5f807b 100644 --- a/tests/config.ini +++ b/tests/config.ini @@ -1,5 +1,5 @@ [influx2] -url=http://localhost:9999 +url=http://localhost:8086 org=my-org token=my-token timeout=6000 diff --git a/tests/test_InfluxDBClient.py b/tests/test_InfluxDBClient.py index fbe9c0b9..34918d09 100644 --- a/tests/test_InfluxDBClient.py +++ b/tests/test_InfluxDBClient.py @@ -18,11 +18,11 @@ def tearDown(self) -> None: self.httpd_thread.join() def test_TrailingSlashInUrl(self): - self.client = InfluxDBClient(url="http://localhost:9999", token="my-token", org="my-org") - self.assertEqual('http://localhost:9999', self.client.api_client.configuration.host) + self.client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org") + self.assertEqual('http://localhost:8086', self.client.api_client.configuration.host) - self.client = InfluxDBClient(url="http://localhost:9999/", token="my-token", org="my-org") - self.assertEqual('http://localhost:9999', self.client.api_client.configuration.host) + self.client = InfluxDBClient(url="http://localhost:8086/", token="my-token", org="my-org") + self.assertEqual('http://localhost:8086', self.client.api_client.configuration.host) def test_ConnectToSelfSignedServer(self): import http.server diff --git a/tests/test_QueryApiDataFrame.py b/tests/test_QueryApiDataFrame.py index 8d8bb526..90a0dcb3 100644 --- a/tests/test_QueryApiDataFrame.py +++ b/tests/test_QueryApiDataFrame.py @@ -287,7 +287,7 @@ def _create_point(index) -> Point: self.assertGreater(len(result), 1) def test_query_without_credentials(self): - _client = InfluxDBClient(url="http://localhost:9999", token="my-token-wrong-credentials", org="my-org") + _client = InfluxDBClient(url="http://localhost:8086", token="my-token-wrong-credentials", org="my-org") with self.assertRaises(ApiException) as ae: query = 'from(bucket: "my-bucket")' \ diff --git a/tests/test_WriteApi.py b/tests/test_WriteApi.py index e5f025c9..efc34409 100644 --- a/tests/test_WriteApi.py +++ b/tests/test_WriteApi.py @@ -374,7 +374,7 @@ def test_write_list_of_list_point_with_default_tags(self): self.assertEqual("LA", record[self.data_center_key]) def test_check_write_permission_by_empty_data(self): - client = InfluxDBClient(url="http://localhost:9999", token="my-token-wrong", org="my-org") + client = InfluxDBClient(url="http://localhost:8086", token="my-token-wrong", org="my-org") write_api = client.write_api(write_options=SYNCHRONOUS) with self.assertRaises(ApiException) as cm: @@ -739,14 +739,14 @@ def test_connection_option_from_conf_file(self): self.client.close() self.client = InfluxDBClient.from_config_file(self._path_to_config(), self.debug) - self.assertEqual("http://localhost:9999", self.client.url) + self.assertEqual("http://localhost:8086", self.client.url) self._check_connection_settings() def test_connection_option_from_env(self): self.client.close() self.client = InfluxDBClient.from_env_properties(self.debug) - self.assertEqual("http://localhost:9999", self.client.url) + self.assertEqual("http://localhost:8086", self.client.url) self._check_connection_settings() def _check_connection_settings(self): diff --git a/tests/test_WriteApiDataFrame.py b/tests/test_WriteApiDataFrame.py index 69dc29e9..f5dcf5eb 100644 --- a/tests/test_WriteApiDataFrame.py +++ b/tests/test_WriteApiDataFrame.py @@ -14,7 +14,7 @@ class DataFrameWriteTest(BaseTest): def setUp(self) -> None: super().setUp() - self.influxDb_client = InfluxDBClient(url="http://localhost:9999", token="my-token", debug=False) + self.influxDb_client = InfluxDBClient(url="http://localhost:8086", token="my-token", debug=False) self.write_options = WriteOptions(batch_size=10_000, flush_interval=5_000, retry_interval=3_000) self._write_client = WriteApi(influxdb_client=self.influxDb_client, write_options=self.write_options) diff --git a/tests/test_WriteApiPickle.py b/tests/test_WriteApiPickle.py index b226f7ac..309e19d1 100644 --- a/tests/test_WriteApiPickle.py +++ b/tests/test_WriteApiPickle.py @@ -11,7 +11,7 @@ class InfluxDBWriterToPickle: def __init__(self): - self.client = InfluxDBClient(url="http://localhost:9999", token="my-token", org="my-org", debug=False) + self.client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org", debug=False) self.write_api = self.client.write_api( write_options=WriteOptions(write_type=WriteType.batching, batch_size=50_000, flush_interval=10_000)) diff --git a/tests/test_point.py b/tests/test_point.py index 2807d3a0..3427602f 100644 --- a/tests/test_point.py +++ b/tests/test_point.py @@ -233,7 +233,7 @@ def test_DateTimeUtc(self): self.assertEqual("h2o,location=europe level=2i 1444897215000000000", point.to_line_protocol()) def test_InstantFormatting(self): - instant = "1970-01-01T00:00:45.999999999Z" + instant = "1970-01-01T00:00:45.808680869Z" point = Point.measurement("h2o") \ .tag("location", "europe") \